2016-04-17 37 views
-1

我需要從url中刪除#散列鍵。並且我使用了這些代碼?是否有任何要添加的內容?請找到我的解決方案?在angularjs頁面重定向時刪除散列鍵

mySchoolApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) { 
    //$locationProvider.html5Mode(true); 
    $routeProvider 
    .when("/", { 
    templateUrl: "templates/login.html", 
    title: 'Login Page', 
    controller: "mainController" 
    }) 
    .when("/login", { 
    templateUrl: "templates/login.html", 
    title: 'Login Page', 
    controller: "mainController" 
    }) 
    .when("/forgot", { 
    templateUrl: "templates/forgot.html", 
    title: 'Forgot Page', 
    controller: "mainController" 
    }) 
    .otherwise({ 
    redirectTo: '/404' 
    }); 
    $locationProvider.html5Mode(true); 
}]); 
+0

雖然增加了LocationProvider我收到無差錯 [$位置:nobase將] HTTP://errors.angularjs .org/1.3.15/$ location/nobase – ArunJaganathan

+0

點擊該鏈接....它向您解釋問題和解決方案! – charlietfl

回答

0

您需要在HTML頭部添加一個基本標記是這樣的:

<base href="/" /> 
+0

但它仍然顯示相同的錯誤。 – ArunJaganathan

+0

有時可能會發生 –