-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-controllerAs.html
33 lines (32 loc) · 1.06 KB
/
angular-controllerAs.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
32
33
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>angular-directive</title>
<script type="text/javascript" src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="app" ng-controller="MyController as ctrl">
<div>
<input type="text" name="" value="" ng-model="ctrl.name">
<span>{{ctrl.name}}</span>
</div>
<div>
<div bai-du></div>
</div>
<script type="text/javascript">
var app = angular.module('app', []);
app.controller('MyController', function(){
});
app.directive('baiDu', function(){
return {
restrict: 'A',
template: '<div>{{MyController.msg}}</div>',
controllerAs: 'MyController',
controller: function(){
this.msg = 'Hey!'
}
}
});
</script>
</body>
</html>