I am facing a scenario where I must resolve one item before obtaining the data necessary to resolve another:
.state('addtrip', {
url: '/addtrip',
templateUrl: 'views/addtrip.html',
controller: 'AddtripCtrl',
resolve: {
auth : function($state, Auth){
return Auth.$requireAuth().then(function(auth) {
return Auth;
}, function(error){
$state.go('login');
});
},
trips : function(rootRef,$firebaseArray){
return $firebaseArray(rootRef).child(auth.uid).$loaded();
}
}
Essentially, I need to first retrieve the auth object and only then fetch the trips for that specific user.
Any suggestions on how to best handle such situations?