AngularJs | ng-list Directive

The ng-list Directive in AngularJS is used for separating input string and convert it into an array of string using a separator. By default comma is used as a default separator. But any custom separator can be used as value of ng-list directive.

Syntax:

 <element ng-list="delimiter"> Contents... </element> 

The value of ng-list specifies the separator to be used for separating the input string.



Example: This example uses ng-list Directive to convert input into array.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head>
    <title>ng-list Directive</title>
  
    <script src=
    </script>
</head>
  
<body ng-app="app" style="text-align:center">
      
    <h1 style="color:green">GeeksforGeeks</h1>
      
    <h2>ng-list Directive</h2>
      
    <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>

chevron_right


Output:
nglist



My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.