我正在制作一个有角度的购物页面,可以通过不同的链接访问。所以我使用的是角度参数指令。我希望它是url/page/parameter
我使用这个
控制器:
var ShopController = (function () {
function ShopController ($routeParams) {
this.label = "Shop List";
this.list = fullList;
this.filter = $routeParams.id;
this.setFilter = function (filter) {
this.filter = filter;
}
}
return ShopController ;
})();
app.controller("ShopController ", ['$routeParams',ShopController ]);
索引链接:
<a ng-class="{active: menu.isActive('/shop) }" ng-link="shop({id: 'prototype'})">
Prototypes
</a>
routeController:
var RoutesController = (function () {
/**
* constructor
* @param router: angular's new router service
*/
function RoutesController($router) {
this.$router = $router;
$router.config([
{ path: '/', redirectTo: '/home' },
{ path: '/home', component: 'home' },
{ path: '/contact', component: 'contact' },
{ path: '/shop/:id', component: 'shop' }
]);
}
// static injection
RoutesController.$inject = ["$router"];
return RoutesController;
})();
// Add the controller to the application
app.controller("RoutesController", RoutesController);
加载时,页面过滤器设置为undefined。但是当我调试页面时,它似乎打到了我的商店2ce。第一次过滤器设置为prototype
的路径选择器,但是在它加载页面之前它再次再次命中该函数并清除过滤器,说明路径参数未定义。
我在这里错过了什么让它发挥作用?