-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
31 lines (31 loc) · 958 Bytes
/
index.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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body ng-app="app">
<input ng-model="a" dand /><button ng-click="a=a+1">change</button>
<div>{{a}}</div>
<script src="lib/angular/angular.js"></script>
<script>
angular.module('app', [])
.directive('dand', function() {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, elem, attrs, ngModelCtrl) {
ngModelCtrl.$parsers.push(function(v) {
return v +1;
});
ngModelCtrl.$formatters.push(function(v){
ngModelCtrl.$setViewValue(v+3);
ngModelCtrl.$render();
return v+3;
})
}
}
});
</script>
</body>
</html>