how to find array size in angularjs


How to find array size in AngularJS

<!DOCTYPE html>
<script src=""></script>

<div ng-app="myApp" ng-controller="namesCtrl">

<p>Looping with objects:</p>
  <li ng-repeat="x in names">

    $scope.names = [
        {name:'Jani'} ,


here i need size of names array

This question is tagged with angularjs

~ Asked on 2016-03-07 17:49:12

The Best Answer is


Just use the length property of a JavaScript array like so:


Also, I don't see a starting <script> tag in your code.

If you want the length inside your view, do it like so:

{{ names.length }}

~ Answered on 2016-03-07 18:01:53


You can find the number of members in a Javascript array by using its length property:

var number = $scope.names.length;

Docs - Array.prototype.length

~ Answered on 2016-03-07 17:51:59

Most Viewed Questions: