/
at_vs_equal_vs_amp.html
34 lines (34 loc) · 995 Bytes
/
at_vs_equal_vs_amp.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
34
<!DOCTYPE html>
<html>
<head>
<title>Angular</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="myCtrl as VM">
<a my-dir
attr1="VM.sayHi('Juan')"
attr2="VM.sayHi('Juan')"
attr3="VM.sayHi('Juan')"></a>
</div>
<script>
angular.module("myApp", [])
.controller("myCtrl", [function(){
this.sayHi = function(name){
return ("Hey there, " + name);
}
}])
.directive("myDir", [function(){
return {
scope: { attr1: "=", attr2: "@", attr3: "&" },
link: function(scope){
console.log(scope.attr1); // logs "Hey there, Juan"
console.log(scope.attr2); // logs "VM.sayHi('Juan')"
console.log(scope.attr3); // logs "function (a){return h(c,a)}"
console.log(scope.attr3()); // logs "Hey there, Juan"
}
}
}]);
</script>
</body>
</html>