My goal is to retrieve data from a server and transfer it to a service before the completion of a route change:
when(
'/detail/:id',
{
templateUrl: './partials/views/detail.php',
controller: 'detailCtrl',
resolve: {
init: function($route,$q,shipmentn){
var deffered = $q.defer();
shipmentn.getSingle($route.current.params.id).then(function(promise){
shipmentn.data = promise.data;
deffered.resolve(promise);
});
return deffered.promise;
}
}
}
)
It's worth noting that I've placed this logic inside the then()
function to ensure the request is complete.
However, I find it frustrating that I need to inject an additional dependency (init
) into my controller and return a promise that is not utilized.
Is there a way for me to work around this issue?