-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path04.scope-inheritence.html
46 lines (37 loc) · 966 Bytes
/
04.scope-inheritence.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
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html>
<head>
<title>Angular Scope Inheritence</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script type="text/javascript">
var sample = angular.module("sample", []);
sample.controller("emp", ["$scope", function($scope){
$scope.name = "Rupa";
}]);
sample.controller("empDetails", ["$scope", function($scope){
$scope.sal = 3000;
$scope.dept = "IT";
}]);
sample.controller("empPaycheck", ["$scope", function($scope){
$scope.getTaxes = function(){
return $scope.sal * 30/100;
};
$scope.getNet = function(){
return $scope.sal - $scope.getTaxes();
};
}]);
</script>
</head>
<body ng-app="sample">
<div ng-controller="emp">
{{name}} details:
<div ng-controller="empDetails">
{{name}} earns {{sal}} and works in {{dept}}.
<div ng-controller="empPaycheck">
Taxes : {{getTaxes()}}
Net : {{getNet()}}
</div>
</div>
</div>
</body>
</html>