gpt4 book ai didi

AngularJS - 如何关闭 hashbang 模式

转载 作者:行者123 更新时间:2023-12-05 01:02:27 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





AngularJS routing without the hash '#'

(10 个回答)



angularjs 1.6.0 (latest now) routes not working

(5 个回答)


去年关闭。




我有一个网页,上面有两个 AngularJS 应用程序。因为有两个应用程序,我必须将应用程序引导到页面上。我正在引导这样的应用程序:

// Bootstrap the first app
var app1 = angular.module('app-1', []);
app1.controller('App1Controller', ['$scope', '$window', function ($scope, $window) {
}]);
angular.bootstrap($('#app1'), ['app-1']);

// Bootstrap the second app
angular.bootstrap($('#app-2'), ['my-app-name']);

我的问题是,我如何完全关闭 hashbangs?我没有使用 AngularJS 进行 View 管理。我用它做其他事情。但是出于某种原因,当我使用 Angular 访问带有 IE8 的页面时,用户会被重定向到一个带有 hashbang 的页面。 hashbang 会导致服务器端错误。出于这个原因,我需要关闭它。我怎么做?

最佳答案

您可以打开 angular html5 push 状态,它应该可以清除任何散列刘海:

app1.config(['$locationProvider', function($locationProvider) {
$locationProvider.html5Mode(true);
}]);

关于AngularJS - 如何关闭 hashbang 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26549724/

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