forked from shyamseshadri/angularjs-up-and-running
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathng-bind-once.html
31 lines (29 loc) · 982 Bytes
/
ng-bind-once.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!-- File: chapter2/ng-bind-once.html -->
<html ng-app="notesApp">
<head><title>Notes App</title></head>
<body ng-controller="MainCtrl as ctrl">
<button ng-click="ctrl.changeMe()">CHANGE</button>
<div ng-repeat="note in ctrl.notes">
Without Bind Once: <div class="label" ng-bind="note.label"></div>
With Bind Once: <div class="label" ng-bind="::note.label"></div>
</div>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/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}
];
self.changeMe = function() {
self.notes[1].label = 'Changed Note';
};
}]);
</script>
</body>
</html>