Last active
January 13, 2018 23:22
-
-
Save agrcrobles/4bd59a37a7e364d1cba3 to your computer and use it in GitHub Desktop.
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
.service('AdminPlantsDevicesCtrlInit', [ | |
// Dependencias | |
'$q', | |
'$route', | |
'Plant', | |
'Notify', | |
function($q, $route, Plant, Notify) { | |
return { | |
prepare: function() { | |
var | |
defer = $q.defer(), | |
defer2 = $q.defer(), | |
params = $route.current.params | |
; | |
// Load plant data | |
Plant.get(params.idPlant) | |
.then(function(plant) { | |
defer.resolve(plant); | |
},function(reason) { | |
Notify.error(reason); | |
defer.reject(reason); | |
}); | |
// Load dataloggers data | |
Plant.getDataloggers(params.idPlant) | |
.then(function(dataloggers) { | |
defer2.resolve(dataloggers); | |
},function(reason) { | |
Notify.error(reason); | |
defer2.reject(reason); | |
}); | |
return $q.all({ | |
plant: defer.promise, | |
dataloggers: defer2.promise | |
}); | |
} | |
}; | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment