AngularJS Tutorial - ng-repeat with key and value pair








The following code shows how to use ng-repeat with key and value pair.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from   w w  w . j  a va  2s  .c o m-->
<body ng-app="myApp">
  <div ng-controller="MyCtrl">
<ul>
    <li ng-repeat="(key, value) in school.sub">first language is = {{value}}</li>
</ul>
</div>
<script type='text/javascript'>
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {

    $scope.school = {
        name: "A",
        sub: {
            firstlang: "Java"
        }
    }
}
</script>
</body>
</html>

The code above is rendered as follows: