Skip to content

Instantly share code, notes, and snippets.

@dougrchamberlain
Created September 15, 2015 12:28
Show Gist options
  • Save dougrchamberlain/5b99d726932ffda57dd8 to your computer and use it in GitHub Desktop.
Save dougrchamberlain/5b99d726932ffda57dd8 to your computer and use it in GitHub Desktop.
sample of moving urls out of methods
angular
.module("stepManager")
.factory("stepManagerService", ["$resource", "$q", "$filter", "stepTypeService", "stepValidationService",
function ($resource, $q, $filter, stepTypeService, stepValidationService) {
"use strict";
var internalResource = $resource("/steps/:id", {id: "@id"}, {
"delete": {method: "DELETE", params: {id: "@id"}},
"new": {method: "POST"}
});
var saveStep = function (toSave) {
var getAllSteps = querySteps();
return $q(function (resolve, reject) {
getAllSteps.then(function (result) {
stepValidationService.validate(toSave, result);
if (toSave.isValid) {
internalResource.save(toSave);
resolve(toSave);
}
else {
reject(toSave);
}
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment