Created
September 15, 2015 12:28
-
-
Save dougrchamberlain/5b99d726932ffda57dd8 to your computer and use it in GitHub Desktop.
sample of moving urls out of methods
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("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