1
我配置ng-view
像如下:如何在使用module.config/ng-view時使用href ID?
angular.module("app", ["ngRoute"])
.config(["$locationProvider", "$routeProvider", function($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when("/", {
templateUrl: "views/home.html",
controller: "homeCtrl"
})
.otherwise({
redirectTo: "views/error.html"
});
}]);
的事情是,現在,只要我點擊喜歡的東西下面,它重定向我到error.html
頁面。
<a href="#mobile_app">Mobile</a>
而且,我看到一個空白頁,而它應該顯示error.html
內容。這個過程沒有錯誤。
我如何在這種情況下href
ID?另外爲什麼error.html
頁面沒有顯示(即使我不希望它顯示,如果用戶點擊一個ID,我想知道它爲什麼不顯示)?
你是什麼意思「路由配置你必須趕上/ mobile_app」?我並沒有改變視圖,只是使用特定的id來標記偏移量。 – Elfayer 2014-09-25 11:35:58
我的意思是,.when(「/ mobile_app」,{ templateUrl:「views/home.html」, controller:「homeCtrl」 }) – katmanco 2014-09-25 11:37:45