i am using ionic framework which uses the uiRouter.
In my code i am going from two different views to a single view and i want to do different actions base on where the user came from.
The common landing view is "result" currently my result state is set up as such
.state('tab.result', {
url: '/result',
params: {
value1: null,
value2:null,
value3:null
},
views: {
'tab-home': {
templateUrl: 'templates/home-result.html',
controller: 'resultCtrl'
}
}
})
i have two paths from different view
1)
$state.go("tab.result",{ 'value1':somevalue,'value1':somevalue,'value1':somevalue});
and in another view i am linking to it like so:
2)
<ion-item ui-sref="tab.result">result</ion-item>
how do i setup my controller in my result view so i know where the user came from?
答案 0 :(得分:2)
也许只记得$ rootState中的先前状态?
$rootScope.$on('$stateChangeSuccess',
function(event, toState, toParams, fromState, fromParams){
$rootScope.previousState = fromState;
$rootScope.previousParams = fromParams;
})