Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs:$locationProvider.hashPrefix(“!”);_Javascript_Jquery_Angularjs_Hashbang - Fatal编程技术网

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

Javascript Angularjs:$locationProvider.hashPrefix(“!”);,javascript,jquery,angularjs,hashbang,Javascript,Jquery,Angularjs,Hashbang,我想将url显示为“www.test.com/!#”,因为我使用的是$locationProvider.hashPrefix(“!”);但它将url显示为“www.test.com/#!”。我要在散列前加“!”而不是在散列后加 谢谢 var app = angular.module('app', []); app.config(function ($routeProvider, $locationProvider) { $locationProvider.html5Mode(false)

我想将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中开始,而不是尝试使用Angular

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


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

是否有任何方法可以使用angularjs进行操作$locationProvider.hashPrefix(!”)的名称应该在哈希之前附加它。为什么它出现在哈希之后。