-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path11.custom-directives.js
74 lines (63 loc) · 1.59 KB
/
11.custom-directives.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var app = angular.module("app", []);
app.controller('emp', ['$scope', 'empService', 'empServiceById', function($scope, empService, empServiceById){
empService.getEmp(function(res){
$scope.Employee = res;
});
$scope.doSearch = function(){
empServiceById.getEmpById($scope.empSearchNo, function(result){
console.log(result);
$scope.empno = result.empno;
$scope.ename = result.ename;
$scope.sal = result.sal;
$scope.deptno = result.deptno;
$scope.hiredate = result.hiredate;
$scope.dob = result.dob;
});
};
$scope.msg = "Calling message from controller";
}]);
app.service('empService', ["$http", function($http){
this.getEmp = function(cb){
$http({
url : 'http://localhost:3000/allemp/',
method : 'get'
}).then(function(res){
cb(res.data);
}, function(err){
cb(err.data);
});
};
}]);
app.service("empServiceById", ["$http", "$log", function($http, $log){
this.getEmpById = function(empno, cb){
$http({
url: 'http://localhost:3000/emp?empno=' + empno,
method : 'GET'
}).then(function(res){
cb(res.data);
},function(err){
$log.error("Error Occured");
});
};
}]);
app.directive('myMessageInfo', function(){
return {
//template : "<strong>My very first message</strong>"
template : "<strong>{{msg}}</strong>",
}
});
app.directive('myMessageInfoScript', function(){
return {
templateUrl : "templates/my-message-info.html",
}
});
app.directive('empDetailsAll', function(){
return {
templateUrl : "templates/emp-details-all.html"
}
});
app.directive('empDetails', function(){
return {
templateUrl : "templates/emp-details.html"
}
});