Angularjs:$ locationProvider.hashPrefix(“!”);

我想将url显示为“www.test.com/!#”,因为我使用的是$ locationProvider.hashPrefix(“!”); 但它显示url为“www.test.com/#!” 。 我想要 ”!” 哈希之前不哈希。

谢谢

var app = angular.module('app', []); app.config(function ($routeProvider, $locationProvider) { $locationProvider.html5Mode(false); $locationProvider.hashPrefix("!"); $routeProvider.when('/', { templateUrl: "app.html", controller: "AppCtrl" } ) .when('/Program', { templateUrl: "detail1.html", controller: "Redirect" }) .when('/Program/123456/channel/78458585', { templateUrl: "details.html", controller: "Detail" }); }); app.controller("AppCtrl", function ($scope) { }); app.controller("Detail", function ($scope, $location) { }); app.controller("Redirect", function ($scope, $location) { $location.path("/Program/123456/channel/78458585") }); 

如果你想要一个! 在片段标识符开始之前的URL中,您需要将其放在URL中以开始,而不是尝试使用Angular。

http://www.example.com/#foohttp://www.example.com/#!foo是同一页面的不同部分。

但是http://www.example.com/#foohttp://www.example.com/!#foo完全是不同的页面。