Check loop index in ng-repeat

Description

The following code shows how to check loop index in ng-repeat.

Example


<!doctype html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.js"></script>
</head><!-- www.j av a 2 s . c  o m-->
<body ng-app="myModule">
   <div ng-controller="TodoCtrl">
    <pre>{{items}}</pre>
        <div ng-repeat="item in items">
            <div ng-show="$index != 4">{{ item }} </div>
</div>
<script type='text/javascript'>
var myModule = angular.module('myModule', []);

myModule.controller('TodoCtrl', function($scope,$filter) {
   $scope.items = [
    "aaa",
    "bbb",
    "ccc",
    "ddd",
    "eee",
    "fff",
    "ggg"
  ];
});
myModule.$inject = ['$scope','$filter'];
</script>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities