AngularJS isArray() is one of the useful ng function. This function is used to identify if a reference is array or not. This function return Boolean which means , it will return true if the reference is an array, return false if the reference is not an array.
Syntax:
angular.isArray(value);
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<!DOCTYPE html> <html ng-app="myapp"> <head> <!-- www.arjunphp.com --> <title>AngularJS isArray() - arjunphp.com</title> <script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"> </script> </head> <body> <div ng-controller="AppController"> <br><br> Is the <b>{{sourceArray}}</b> an array: <b> {{ sourceAryIsArray }} </b> <br><br> Is the <b>{{sourceString}}</b> an array: <b> {{ sourceStringIsArray }} </b> </div> <script type="text/javascript"> var app = angular.module('myapp', []); app.controller('AppController', function($scope) { $scope.sourceArray = [1,2,3,4,5,6]; $scope.sourceString = "www.arjunphp.com"; $scope.sourceAryIsArray = angular.isArray($scope.sourceArray); $scope.sourceStringIsArray = angular.isArray($scope.sourceString); }); </script> </body> </html> |
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.