gpt4 book ai didi

javascript - 访问特定页面时清除 $ionicHistory

转载 作者:行者123 更新时间:2023-11-29 19:16:22 26 4
gpt4 key购买 nike

enter image description here

我在清除 $ionicHistory 时遇到了一些问题.

如上所示,当用户在付款屏幕上点击确定时,我想清除应用程序的整个查看历史记录并将用户重定向到 em>附近屏幕。

需要清除用户从支付屏幕到达的附近屏幕之前的查看历史记录。因此,用户只会在附近 屏幕上看到菜单图标,而不是返回 图标。

实际情况:在用户点击确定付款 屏幕之前的查看历史记录被清除。因此,当用户登陆附近页面并按下返回(他们不应该这样做)时,他们最终会进入付款 再次显示屏幕,但无法访问付款屏幕之前的任何内容。

到目前为止我的代码:

应用程序.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 the above states are matched, use this as the 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>

最佳答案

试试这个

$scope.clearHistory = function() {
$ionicHistory.nextViewOptions({
disableBack: true,
historyRoot: true
});
}

关于javascript - 访问特定页面时清除 $ionicHistory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35036181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com