angularjs 路由是如何工作的?
How does angularjs routing work?
我有以下应用程序配置,否则部分似乎一直都赢 为什么细节在这里不匹配?:
var app = angular.module("atTheMovies", ["ngRoute"]);
var config = function ($routeProvider, $locationProvider) {
$routeProvider
.when('/list',
{ templateUrl: "/client/views/list.html" }
)
.when("/details/:id",
{ templateUrl: "/client/views/details.html" })
.otherwise(
{ redirectTo: "/list" });
//$locationProvider.html5Mode(true);
//$locationProvider.html5Mode(true).hashPrefix('!')
}
app.config(["$routeProvider", "$locationProvider",config]);
我的锚标签 href 是这样的:
<a href="#/details/1">Details</a>
<a href="#/details/2">Details</a>
<a href="#/details/3">Details</a>
你可以 href
不用 #
<a href="details/1">Details</a>
<a href="details/2">Details</a>
<a href="details/3">Details</a>
此处为 Plunker 示例
Plunker
我有以下应用程序配置,否则部分似乎一直都赢 为什么细节在这里不匹配?:
var app = angular.module("atTheMovies", ["ngRoute"]);
var config = function ($routeProvider, $locationProvider) {
$routeProvider
.when('/list',
{ templateUrl: "/client/views/list.html" }
)
.when("/details/:id",
{ templateUrl: "/client/views/details.html" })
.otherwise(
{ redirectTo: "/list" });
//$locationProvider.html5Mode(true);
//$locationProvider.html5Mode(true).hashPrefix('!')
}
app.config(["$routeProvider", "$locationProvider",config]);
我的锚标签 href 是这样的:
<a href="#/details/1">Details</a>
<a href="#/details/2">Details</a>
<a href="#/details/3">Details</a>
你可以 href
不用 #
<a href="details/1">Details</a>
<a href="details/2">Details</a>
<a href="details/3">Details</a>
此处为 Plunker 示例 Plunker