-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path09.ngif-nfshow-nghide-ngrepeat.js
46 lines (41 loc) · 1.13 KB
/
09.ngif-nfshow-nghide-ngrepeat.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
var app = angular.module("app", []);
app.controller("emp", ["$scope", "empService", "empServiceById", function($scope, empService, empServiceById){
empService.getEmp(function(r){
$scope.Employee = r;
});
$scope.getEmpDetails = function(){
empServiceById.getEmpById($scope.empSearchNo, function(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.isSalAbove6kb = parseInt(result.sal) > 6000;
});
};
}]);
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(sucess){
cb(sucess.data);
},function(error){
$log.error("Error occured");
});
};
}]);
app.service("empService", ["$http", "$log", function($http, $log){
this.getEmp = function(cb){
$http({
url: 'http://localhost:3000/allemp/',
method : 'GET'
}).then(function(sucess){
cb(sucess.data);
},function(error){
$log.info(error.data);
});
};
}]);