Using the same html template in angular with ng-repeat directive
The ng-repeat directive in angular is useful for using the same html over and over again with a bunch of objects that have similar structure.
An ng-repeat angular example
Say you have a bunch pf objects, and each object has the same properties. It is possible to use ng-repeat to use some html as a template for all instances of the objects in an array that I have in my $scope.
Say I have an array of objects in $scope variable that contain information for enemy’s in some kind of game. I want all the info displayed using the same standard html template.
So A template might look like this
Desc:
Attack:
Defence:
A controller would have the $scope, In this example I am using a literal, but It could be grabbed from a service in some kind of real example.
JS
|
|
As such ng-repeat is a pretty useful directive.