javascript - Clear $ionicHistory when particular page is accessed -


enter image description here

i having bit of problem clearing $ionichistory.

as seen above when user clicks on ok on payment screen, i'd clear out app’s entire view history , redirect user nearby screen.

the view history prior nearby screen on user reaches payment screen needs cleared. user sees menu icon on nearby screen, instead of back icon.

what happens: view history prior payment screen on user clicks ok on cleared. when user lands on nearby page, , presses back (which should not able do), end on payment screen again, cannot access prior payment screen.

my code far:

app.js

.config(function($stateprovider, $urlrouterprovider) {   $stateprovider     .state('app', {     url: '/app',     abstract: true,     templateurl: 'templates/menu.html',     controller: 'appctrl'   })  .state('app.payment', {   url: '/payment/:business',   views: {     'menucontent': {       templateurl: 'templates/payment.html',       controller: 'bookctrl'     }   } })  .state('app.service', {   url: '/services/:service',   views: {     'menucontent': {       templateurl: 'templates/service.html',       controller: 'servicectrl'     }   } });  // if none of above states matched, use fallback $urlrouterprovider.otherwise('/app/services'); }); 

controller.js

angular.module('starter.controllers', [])  .controller('businessctrl', function($scope, $state, servicesdata, $stateparams, $ionichistory) {   $scope.business = servicesdata.getbusiness($stateparams.business);   $scope.service = servicesdata.getbusinessservicecategory($stateparams.business);   $scope.clearhistory = function() {     $ionichistory.clearhistory();   } })  .controller('servicectrl', function($scope, servicesdata, $stateparams) {   $scope.service = servicesdata.getselectedservice($stateparams.service);   $scope.businesslist = servicesdata.getallbusinessinservicecategory($stateparams.service); }) 

payment.html

<ion-footer-bar>     <div class="button-bar" ng-controller="businessctrl">         <a class="button button-balanced" style="border-radius:0px" ui-sref="app.services" ng-click="clearhistory()">ok</a>         <a class="button button-stable" style="border-radius:0px" href="">view receipt</a>     </div> </ion-footer-bar> 

try this

$scope.clearhistory = function() {     $ionichistory.nextviewoptions({         disableback: true,         historyroot: true     }); } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -