-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangularjs_factory.html
More file actions
51 lines (43 loc) · 923 Bytes
/
angularjs_factory.html
File metadata and controls
51 lines (43 loc) · 923 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.2/angular.min.js"> </script>
</head>
<script>
var personman = function(info){
var factory = info;
return {
getfirst : function(){
return factory.first;
},
getlast : function(){
return factory.last;
},
getfull : function(seperator){
return factory.first + seperator + factory.last;
}
}
}
angular.module('myApp', [])
.value('info', {
first: '' ,
last : '',
})
.factory('fact', personman)
.controller('cont', function($scope, info, fact){
info.first= 'sai';
info.last = 'teja';
$scope.insta= info;
$scope.inst = fact;
})
</script>
<body ng-app="myApp">
<div ng-controller="cont">
{{inst.getfirst()}}
{{inst.getlast()}} </br>
{{inst.getfull('##')}} </br>
<input type="text" ng-model="insta.first">
<input type="text" ng-model="insta.last">
</div>
</body>
</html>