Reputation: 297
I want to know how $ionicHistory internally works . If i call a function named goBack() inside will it work fine . Or any other tags i need to add in my html code . Please help me out with your suggestions .
i have used both
$scope.goBack = function() {
console.log('Going back');
$ionicViewService.getBackView().go();
}
or
$scope.goBack = function() {
console.log('Going back');
$ionicHistory.goBack();
}
I tried both approach . everytime i am getting same output . you can see where 2nd logout is there , I am trying to navigate from that page to 1st page(1st logout ). But it's coming like this . Please help me out how to resolve this .
Upvotes: 2
Views: 659
Reputation: 297
Thanks @Sa E Chowdary Finally my code worked
Few changes i made in my js file
.state('app.profile', {
cache: false,// disabled cache
url: './profile',
views: {
'menuContent': {
// templateUrl: 'templates/profile.html',
templateUrl: 'templates/profile.html',
controller: 'ProfileCtrl'
},
'fabContent': {
template: ''
}
}
})
in my controller
setTimeout(
function()
{ $scope.goBack = function() {
console.log('Going back');
$ionicHistory.goBack();
// window.history.go(-1);
};
}, 2000);
Main changes i did is disabled cache otherwise $ionicHistory was not behaving properly .
Again Thanks All
Upvotes: 2
Reputation: 2075
According to the documentation,it will track the views while user navigating in the application....an Ionic app is able to keep track of the previous view, the current view, and the forward view (if there is one).
And it contains some methods you can found in documentation.... coming to your case you need to write some code in your js according to your requirement like whether you want to go to previous view or next view and dont forgot to add or inject the dependency.... you need to use something like this
$ionicHistory.nextViewOptions({
//your code
});
and
$ionicHistory.backView({
//your code
})
you may use $ionicViewService
also and you can find there how it will works
Upvotes: 1
Reputation: 981
yes goBack()
will also work in your controller code.
use like this : $ionicHistory.goBack();
Upvotes: 1