Hii,
Learn how we can repeat html element without using any conditional loop by using AngularJs.
To repeat html elements using AngularJs we use ng-repeat which is a directive of AngularJs, ng-repeat directive is used to repeat an HTML element.
Go through this simple example to learn how we can use ng-repeat i.e an AngularJs directive
Example:In this example ng-app(To initialise an AngularJS application),ng-init(To initialise application data),ng-repeat(To repeat HTMl element) directives and an expression {{expression}} (to bind data to HTML) are used.
<div ng-app="" ng-init='week=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]'>
<p>List of days in a week using ng-repeat directive</p>
<ul>
<li ng-repeat="days in week">
{{ days }}
</li>
</ul>
</div>
Output:
List of days in a week using ng-repeat directive
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday
- Saturday
- Sunday
Note: Must include this link in your file
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
0 Comment(s)