Search code examples
angularjssplitangular-nglist

ng-list split with blank delimiter


is there a way to have ng-list split in the same way string.split('')(a blank string for the delimiter) would? the split() function splits everything when it is a blank string meaning 'hello world'.split('') would return ['h','e','l','l','0',' ','w','o','r','l','d'] however when i plug a blank string into ng-list it defaults back to its default delimiter of ", " is there any way to get the behavior im looking for from ng-list? I've already tried this

<textarea ng-model='text' ng-list='' ng-trim='false'></textarea>

an example can be found here


Solution

  • This isn't a very pretty way of doing it but by removing the default of ", " in the angular.js file (line 24,620 in version 1.4.8) means that the default becomes an empty string allowing this to work.

    Update There's also a loophole that allows this but it's a bit of an oddity. The theory is you set the delimiter to a space but then set the ng-trim to true meaning it trims away the space and makes a blank delimiter