Skip to content

Instantly share code, notes, and snippets.

@yllieth
Last active August 29, 2015 14:10
Show Gist options
  • Save yllieth/383f57aa557f09aba0e4 to your computer and use it in GitHub Desktop.
Save yllieth/383f57aa557f09aba0e4 to your computer and use it in GitHub Desktop.
AngularJS templates
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);
}
}
});
/**
* 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
});
@yllieth
Copy link
Author

yllieth commented Dec 4, 2014

This find will lives under app/modules/project/scripts/models/project.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment