Last active
August 29, 2015 14:10
-
-
Save yllieth/383f57aa557f09aba0e4 to your computer and use it in GitHub Desktop.
AngularJS templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module('myHubApp', [...]) | |
.factory('apiRestangular', function(Restangular, baseUrl) { | |
return Restangular.withConfig(function(RestangularConfigurer) { | |
RestangularConfigurer.setBaseUrl(baseUrl.API); | |
}); | |
}) | |
.factory('api', function(apiRestangular) { | |
return { | |
one: function(resource, id) { | |
return apiRestangular.one(resource, id); | |
}, | |
all: function(resource) { | |
return apiRestangular.all(resource); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Model for /projects resource | |
* | |
* API version: v1 | |
* API documentation: https://developer.predicsis.com/v1/project/ | |
*/ | |
angular.module('predicsis.api.model') | |
.service('projects', function(api) { | |
var that = this; | |
// CRUD methods | |
that.getList = function() { | |
return api.all('projects').getList(); | |
}; | |
that.getOne = function(projectId) { | |
return api.one('projects', projectId).get(); | |
}; | |
that.create = function(newProject) { | |
return api.all('projects').post({project: newProject}); | |
}; | |
that.update = function(projectId, updates) { | |
return api.one('project', projectId).patch({project: updates}); | |
}; | |
that.remove = function(projectId) { | |
return api.one('project', projectId).remove(); | |
}; | |
// Other methods | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This find will lives under
app/modules/project/scripts/models/project.js