【发布时间】:2017-02-10 05:33:37
【问题描述】:
有人可以解释我如何使用参数路由到 URL 吗?
例如id 喜欢点击产品并通过 Id 打开产品的更多信息。
到目前为止我的路线......
angular.module('shop', ["customFilters", "cart", "ngRoute"])
.config(function ($routeProvider){
$routeProvider.when("/complete", {
templateUrl: "../app/views/orderComplete.html"
});
$routeProvider.when("/placeorder", {
templateUrl: "../app/views/placeOrder.html"
});
$routeProvider.when("/checkout", {
templateUrl: "../app/views/checkoutSummary.html"
});
$routeProvider.when("/products", {
templateUrl: "../app/views/productList.html"
});
$routeProvider.when("/product:", {
templateUrl: "../app/views/product.html"
});
$routeProvider.otherwise({
templateUrl: "../app/views/productList.html"
});
});
所以通过点击...
<a class="btn btn-default" href="#/product/{{item.id}}">More Info</a>
我想被路由到 product/{{id}}.html ...
有人可以告诉我我在...中缺少什么
$routeProvider.when("/product:id", {
templateUrl: "../app/views/product.html"
});
【问题讨论】: