Use list formatter if you wish to convert the user entered string to an array.
<input type="text" name="bindExpression" ng:format="list">
var userInputString = angular.formatter.list.format(modelValue); var modelValue = angular.formatter.list.parse(userInputString);
{Array}
– Array parsed from the entered string.
Enter a list of items: <input type="text" name="value" ng:format="list" value=" chair ,, table"/> <input type="text" name="value" ng:format="list"/> <pre>value={{value}}</pre>
it('should format lists', function(){ expect(binding('value')).toEqual('value=["chair","table"]'); this.addFutureAction('change to XYZ', function($window, $document, done){ $document.elements('.doc-example-live :input:last').val(',,a,b,').trigger('change'); done(); }); expect(binding('value')).toEqual('value=["a","b"]'); });