AngularJS - 如何关闭 hashbang 模式 [英] AngularJS - How to turn off hashbang mode

查看:27
本文介绍了AngularJS - 如何关闭 hashbang 模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an web page that has two AngularJS apps on it. Because there are two apps, I have to bootstrap the apps onto the page. I'm bootstrapping the apps like this:

// 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 进行视图管理.我用它做其他事情.但出于某种原因,当我使用 IE8 和 Angular 访问页面时,用户会被重定向到一个带有 hashbang 的页面.hashbang 会导致服务器端错误.出于这个原因,我需要关闭它.我该怎么做?

My question is, how do I turn off hashbangs altogether? I am not using AngularJS for view management. I am using it for other things. For some reason though, when I visit a page with IE8 with Angular, the user gets redirected to a page with a hashbang in it. The hashbang causes a server-side error. For that reason, I NEED to turn that off. How do I do that?

推荐答案

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

You can turn on the angular html5 push state, which should scrub any hash bangs:

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

这篇关于AngularJS - 如何关闭 hashbang 模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆