问题描述
例如:
http://localhost/#!/login.html
我不需要!".我将如何删除它?
I don't need "!". How would I remove it?
eg:http://localhost/#/login.html
这是我的路由器代码:
// Redirect any unmatched url
$urlRouterProvider.otherwise("/login.html");
$stateProvider.state('login', {
url: "/login.html",
templateUrl: "views/login.html",
data: {pageTitle: "login", isLeft: false},
controller: "LoginCtrl",
resolve: {
deps: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'myApp',
files: [
'controllers/LoginCtrl.js'
]
});
}]
}
});
我认为Angular-ui-router可能有问题,但是我找不到解决方法.
I think Angular-ui-router might have a problem, but I can't find the solution.
谢谢!
推荐答案
哈希模式
Hashbang模式是AngularJS用于向您的Angular提供深度链接功能的一种技巧应用.在hashbang模式(对于html5模式的后备)中,URL路径使用前置的#字符.它们不重写标签,不需要任何服务器端支持.哈希邦如果没有其他说明,则模式是AngularJS使用的默认模式.hashbang URL看起来像:
Hashbang mode is a trick that AngularJS uses to provide deep-linking capabilities to your Angularapps. In hashbang mode (the fallback for html5 mode), URL paths take a prepended # character.They do not rewrite tags and do not require any server-side support. Hashbangmode is the default mode that AngularJS uses if it’s not told otherwise.A hashbang URL looks like:
要明确并配置hashbang模式,需要在应用模块
To be explicit and configure hashbang mode, it needs to be configured in the config function on anapp module
要配置hashPrefix:
angular.module('myApp', ['ngRoute'])
.config(['$locationProvider', function($locationProvider) {
$locationProvider.html5Mode(false);
$locationProvider.hashPrefix('!');
}]);
这篇关于我使用的是棱角分明,而我的网址始终带有“!" (感叹号)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!