Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

AngularJs | ng-list Directive

  • Last Updated : 26 Aug, 2021

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.  

html




<!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>

Output:  

nglist

Supported Browser:

  • Google Chrome
  • Microsoft Edge
  • Firefox
  • Opera
  • Safari
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!