我想设置一条路由,该路由可以采用可选 ID 来查找要使用的模型,同时在未传入模型的情况下仍支持默认模型?
例如:
/home/
/order/
/order/123
/order/123/shipping
/someotherroute/
是否有一种干净的方法可以在不使用查询字符串参数的情况下执行此操作?
最佳答案
您可以使用索引路由作为默认订单,并使用子资源来保存您指定的订单。
this.resource('order', function(){
// this.route('index'); this is given to you as a freebie, put your default order in here
this.resource('specified', {path: ':id'});
})
关于javascript - ember.js - 如何设置具有可选 ID 的路由以进行查找和后备默认模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26188461/