JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://code.angularjs.org/1.6.6/angular.min.js"></script>
<script>
angular.module('myApp',[])
.controller('Ctrl', ['$scope', function($scope) {
angular.extend($scope, {
getList: function() {
/*
* there are two ways to define hash key - as a constant or as a function, both must
* return values primitive values that are equivalent for objects that are
* equvivalent. if you use a function then it should ideally be O(1) or O(n) at
* most if you expect the object to be small.
*/
return [{name:'John', age:25, $$hashKey: 0}, {name:'Mary', age:28, $$hashKey: function() {return JSON.stringify(this)}}];
}
});
}]);
</script>
<div ng-app="myApp">
<div ng-controller="Ctrl">
I have {{getList().length}} friends. They are:
<ul>
<li ng-repeat="friend in getList()">
[{{$index + 1}}] {{friend.name}} who is {{friend.age}} years old.
</li>
</ul>
</div>
</div>