-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab22.html
More file actions
51 lines (45 loc) · 1.68 KB
/
lab22.html
File metadata and controls
51 lines (45 loc) · 1.68 KB
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
47
48
49
50
51
<!DOCTYPE html>
<!-- AngularJS : An Alternative Approach to Controllers -->
<html>
<head>
<title>AngularJS : An Alternative Approach to Controllers</title>
<meta charset="utf-8" />
<script src="Scripts/angular.min.js"></script>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<script>
var mainApp = angular.module("mainApp", []).
controller("alterCntrl", function ($scope) {
this.title = "AngularJS : An Alternative Approach to Controllers";
this.sayhi = function () {
alert("Hello Amit Mishra");
}
return $scope.alterCntrl = this;
});
angular.element(document).ready(function () {
angular.bootstrap(document, ["mainApp"]);
});
</script>
</head>
<body ng-controller="alterCntrl" class="container">
<h1>{{alterCntrl.title}}</h1>
<div >
<div class="btn btn-primary" ng-click="alterCntrl.sayhi();">Click Me!!</div>
</div>
<div class="blockquote">
<p>Calling function by controller $scope.</p>
<p>when we call function from controller name it so clear which function belong to Controller</p>
<pre>
<code>
var mainApp = angular.module("mainApp", []).
controller("alterCntrl", function ($scope) {
this.title = "AngularJS : An Alternative Approach to Controllers";
this.sayhi = function () {
alert("Hello Amit Mishra");
}
return $scope.alterCntrl = this; << This is Alternative Approach to controllers.
});
</code>
</pre>
</div>
</body>
</html>