Before a state is loaded, I wish to resolve a factory using the data from another factory.
My situation:
"taskVariables": function (getTask, getTaskVariables, $stateParams) {
getTask.get({'task': $stateParams.taskId}).success(function(data) {
console.log("I'm here");
return getTaskVariables.get({'processInstanceId': data.processInstanceId});
});
return false;
console.log("I have failed you master")
},
Factory:
.factory('getTask', function ($resource) {
return $resource('api/task/get/:task', {'user': '@user', 'task': '@task'}, {
'get': {
method: 'GET',
transformResponse: function (data) {
data = angular.fromJson(data);
return data;
}
}
})
})
The thing is that I think that one factory is loading faster than the other, thus the data will be undefined on page load, but that is just me speculating.
Is there a way to achieve this with maybe a promise or some kind?
Thanks in advance,