簡體   English   中英

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

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

我想將url顯示為“www.test.com/!#”,因為我正在使用$ locationProvider.hashPrefix(“!”); 但它顯示網址為“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完全是不同的頁面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM