AngularJS angular.isArray() Function (original) (raw)

Last Updated : 06 Sep, 2022

The angular.isArray() Function in AngularJS is used to return TRUE if the reference is an array and FALSE if it is not an array.

Syntax:

angular.isArray(value);

Parameter:

Return value: Returns TRUE if the value is an array else it will return FALSE.

Example 1: This example describes the basic usage of angular.isArray() Function in AngularJS.

HTML `

angular.isArray()

GeeksforGeeks

angular.isArray()

Sorting Algos:
{{i.name}}


isArray: {{isArray}}
<script>
    var app = angular.module("app", []);
    app.controller('geek', ['$scope', 
    function ($scope) {
        $scope.sort = [];
        var values = [
            { name: 'Merge sort' },
            { name: 'Quick sort' },
            { name: 'Bubble sort' }
        ];
        if (angular.isArray(values)) {
            $scope.isArray = true;
            angular.forEach(values, 
            function (value, key) {
                $scope.sort.push(value)
            })
        }
    }]);
</script>

`

Output:

isarray

Example 2: This is another example that describes the usage of angular.isArray() Function in AngularJS.

HTML `

angular.isArray()

GeeksforGeeks

angular.isArray()

Input: {{name}}

isArray: {{isArray}}

`

Output:

isarray