angularjs路由如何工作?

时间:2017-04-19 14:52:41

标签: angularjs angularjs-routing

我有以下应用程序配置,否则部分似乎一直都赢了为什么细节不匹配?:

zip()

我的锚标签href是这样的:

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]);

1 个答案:

答案 0 :(得分:0)

您可href而不放#

<a href="details/1">Details</a>
<a href="details/2">Details</a>
<a href="details/3">Details</a> 

此处有一个Plunker示例 的 Plunker