Thursday 16 June 2016

ng-repeat Across Multiple HTML Elements


<html ng-app="notesApp">
<body ng-controller="MainCtrl as ctrl">
<table>
<tr ng-repeat-start="note in ctrl.notes">
<td>{{note.label}}</td>
</tr>
<tr>
<td>value: {{note.value}}</td>
</tr>
<tr ng-repeat-end>
<td>Done: {{note.done}}</td>
</tr>
</table>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js">
</script>
<script type="text/javascript">
angular.module('notesApp', [])
.controller('MainCtrl', [function() {
var self = this;
self.notes = [
{id: 1, label: 'First Note', value:'1', done: false},
{id: 2, label: 'Second Note', value:'2', done: false},
{id: 3, label: 'Finished Third Note', value:'3', done: true}
];
}]);
</script>
</body>
</html>


OUTPUT

First Note
value: 1
Done: false
Second Note
value: 2
Done: false
Finished Third Note
value: 3
Done: true

No comments:

Post a Comment