THE WORLD'S LARGEST WEB DEVELOPER SITE

AngularJS ng-list Directive


Example

Convert user input into an array:

<div ng-app="">

<input ng-model="customers" ng-list/>

<pre>{{customers}}</pre>
Try it Yourself »

Definition and Usage

The ng-list directive converts a string into an array of strings, using a comma as the default separator.

The ng-list directive also converts the other way around, if you have a array of strings you wish to display in an input field as a string, then put the ng-list directive on the input field.

The value of the ng-list attribute defines the separator.


Syntax

<element ng-list="separator"></element>

Supported by <input> and <textarea> elements.


Parameter Values

Value Description
separator Optional, defines the separator, default value is ", "