The ng-list Directive in AngularJS is used for separating input strings and converting them into an array of strings using a separator. By default, the comma is used as a default separator. But any custom separator can be used as the value of the ng-list directive.
Syntax:
Contents...
The value of ng-list specifies the separator to be used for separating the input string.
Example 1: This example uses the ng-list Directive to convert input into an array.
<html>
<head>
<title>ng-list Directivetitle>
<script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
script>
head>
<body ng-app="app" style="text-align:center">
<h1 style="color:green;">
GeeksforGeeks
h1>
<h2>ng-list Directiveh2>
<div ng-controller="geek">
<p>Enter Input:
<input type="text"
ng-model="list"
ng-list="-">
p>
{{list}}
div>
<script>
var app = angular.module("app", []);
app.controller('geek', ['$scope',
function($scope) {
$scope.list = [];
}]);
script>
body>
html>
Output:

Example 2: In this example, when we include the ng-list Directive, then it will convert the text in the input field into an array.
<html>
<head>
<script src=
"https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
script>
head>
<body style="text-align:center">
<h1 style="color:green">GeeksforGeeksh1>
<h2>ng-list Directiveh2>
<div ng-app="">
<p>
Use a comma to separate the
texts in the input field
p>
<input ng-model="content" ng-list/>
<pre>{{content}}pre>
div>
body>
html>
Output:
