Home>

angularjs ng-list directive

angularjs example

Convert user input to an array:

<! Doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="">
<p>In the input box,Enter some text,And separate them with commas:</p>
<input ng-model="customers" ng-list />
<p>When using the ng-list instruction, your input information is converted to an array,It looks like this:</p>
<pre>{{customers}}</pre>
</div>
</body>
</html>

Definition and usage

The ng-list instruction converts a string into an array,And separated by commas.

The ng-list attribute value defines the delimiter.

grammar

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

<input> ;,<select> ;,<textarea> ;, and other editable elements support the directive.

Parameter value

value description
separator Optional, define a separator,The default is", "

  • Previous JS method for randomly taking out several array elements from an array
  • Next iOS implements the cute owl login interface animation