我试图在我的道路上传递一个参数。我试着这样:
route.js
this.route`enter code here`('purchase', {path: '/purchase'}, function () {
this.route('purchaseDetails');
this.route('purchaseEdit', {path:'purchaseEdit?country='}); //showing in the URL
this.route('purchaseReview');
this.route('purchaseConfirmation');
});
重定向,如:
this.transitionTo('purchase.purchaseEdit', "SG");
但不行。有人纠正我吗?
答案 0 :(得分:1)
很好地解释了here。
您也可以这样做。该网址将显示为.../purchase/purchaseEdit/India
this.route('purchase', {path: '/purchase'}, function () {
this.route('purchaseDetails');
this.route('purchaseEdit', {path:'purchaseEdit/:country'}); //showing in the URL
this.route('purchaseReview');
this.route('purchaseConfirmation');
});
在purchaseEdit
的路线中,在获取model
时,您可以获得该国家/地区的价值。
model:function(params)
{
console.log(params); //Contains the dynamic-params declared in the route as object.
return this.store.find('purchasedItem',params.country).then(function(response){
return response;
},function(response){
return "";
});
}