forked from zafarali/learning-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path04-3-scope.html
More file actions
36 lines (33 loc) · 860 Bytes
/
04-3-scope.html
File metadata and controls
36 lines (33 loc) · 860 Bytes
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
35
36
<!DOCTYPE html>
<html>
<head>
<title>scope</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.11/angular.min.js"></script>
<script>
var app = angular.module('myApp', []);
app.controller('Ctrl', ['$scope', function($scope){
$scope.makeCall = function(reciever){
alert("Calling "+reciever+"...");
}
}]);
app.directive('phone', function(){
return {
scope:{
dial:'&'
},
template:'<div>Who would you like to call?'+
'<input type="text" ng-model="who">'+
'<a href="#" ng-click="dial({reciever:who})">Call {{who}}</a></div>'
}
})
</script>
</head>
<body>
<div ng-app="myApp" ng-controller='Ctrl'>
<div phone dial="makeCall(reciever)"></div>
<div phone dial="makeCall(reciever)"></div>
<div phone dial="makeCall(reciever)"></div>
<div phone dial="makeCall(reciever)"></div>
</div>
</body>
</html>