我的网址看起来更像/ foo / bar /而不是/ foo / 23 /
目前我的路线定义如下
App.Router.map(function() {
this.route('index', {path: '/'});
this.resource('category', {path: '/:category_id'}, function() {
this.route('product', {path: ':product_id'});
});
});
这可以按预期工作。为了让网址更具人性化,我需要更改什么?理想情况下,我希望类别和产品网址都包含其[唯一]名称,而不是唯一的ID。我已经尝试将路径更改为/:category_name
,但是网址随后包含模型对象,而不仅仅是名称
答案 0 :(得分:1)
您可以覆盖路线上的序列化功能。
http://emberjs.com/api/classes/Ember.Route.html#method_serialize