angular-isArray-2

 

In this example it will check if angular.isArray returns true then push obj's value in 'nameArr' array and show the name in result window.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome in the AngularJS</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="app"> <div ng-controller="isArrayController"> isArray: {{isArray}} <div ng-repeat="nm in nameArr">{{nm.name}}</div> </div> </body> </html> <script> var app = angular.module("app", []); app.controller('isArrayController', ['$scope', function ($scope) { $scope.nameArr = []; var values = [{ name: 'Jimmi', gender: 'male' }, { name: 'Marry', gender: 'female' }, { name: 'Bob', gender: 'male' }]; if (angular.isArray(values)) { $scope.isArray = true; angular.forEach(values, function (value, key) { $scope.nameArr.push(value) }) } }]); </script>
Output