Thursday 16 June 2016

Angular.js Working with and Displaying Arrays

<html ng-app="notesApp">
<head><title>Notes App</title></head>
<body ng-controller="MainCtrl as ctrl">
<div ng-repeat="note in ctrl.notes">
<span class="label"> {{note.label}}</span>
<span class="status" ng-bind="note.done"></span>
</div>
<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', done: false},
{id: 2, label: 'Second Note', done: false},
{id: 3, label: 'Done Note', done: true},
{id: 4, label: 'Last Note', done: false}
];
}]);
</script>
</body>

</html>


OUTPUT


First Note false
Second Note false
Done Note true
Last Note false




No comments:

Post a Comment