Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.service('MethodProvider', function ($http) {
- var self = this;
- self.get = function (url) {
- var obj = {
- url: url,
- method: 'GET',
- async: true,
- headers: {
- 'Content-Type': 'application/json'
- }
- };
- return $http(obj);
- };
- self.post = function (url, data) {
- var obj = {
- url: url,
- method: 'POST',
- async: true,
- data: JSON.stringify(data),
- headers: {
- 'Content-Type': 'application/json'
- }
- };
- return $http(obj);
- };
- self.put = function (url, data) {
- var obj = {
- url: url,
- method: 'PUT',
- async: true,
- headers: {
- 'Content-Type': 'application/json'
- }
- };
- if (typeof data != 'undefined' && data != null) {
- obj.data = JSON.stringify(data);
- }
- return $http(obj);
- };
- self.delete = function (url) {
- var obj = {
- url: url,
- method: 'POST',
- async: true,
- headers: {
- 'Content-Type': 'application/json'
- }
- };
- return $http(obj);
- };
- return self;
- });
- app.service('UserSrvc', function (MethodProvider) {
- var self = this;
- self.create = function (data) {
- var url = apiUrl + '/user/add';
- return MethodProvider.post(url, data);
- };
- return self;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement