-
Notifications
You must be signed in to change notification settings - Fork 722
Expand file tree
/
Copy pathtodoListSvc.js
More file actions
30 lines (28 loc) · 941 Bytes
/
todoListSvc.js
File metadata and controls
30 lines (28 loc) · 941 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
'use strict';
angular.module('todoApp')
.factory('todoListSvc', ['$http', function ($http) {
$http.defaults.useXDomain = true;
delete $http.defaults.headers.common['X-Requested-With'];
// Add X-Client-ID header to all requests
$http.defaults.headers.common['X-Client-ID'] = 'ClientA';
return {
getItems : function(){
return $http.get(apiEndpoint + '/api/Todo');
},
getItem : function(id){
return $http.get(apiEndpoint + '/api/Todo/' + id);
},
postItem : function(item){
return $http.post(apiEndpoint + '/api/Todo', item);
},
putItem : function(item){
return $http.put(apiEndpoint + '/api/Todo/' + item.id, item);
},
deleteItem : function(id){
return $http({
method: 'DELETE',
url: apiEndpoint + '/api/Todo/' + id
});
}
};
}]);