更新:我升级到rc3并且问题仍然存在。我发现第二个链接点击成功。
Ember.js v1.0.0-rc.3
我的路由器具有嵌套资源,用于上下文:
App.Router.map(function(match) {
this.resource('items', function() {
this.resource('item', { path: ':item_id' }, function() {
this.resource('images', function() {
this.resource('image', { path: ':image_id' });
});
});
});
});
我希望'/ items'重定向到第一项:'/ items / 1'
App.ItemsRoute = Em.Route.extend({
model: function() {
return App.Item.find({});
},
redirect: function() {
var item = this.modelFor('items').get('firstObject');
this.transitionTo('item', item);
}
});
问题:点击/项目错误:
Error: assertion failed: Cannot call get with 'id' on an undefined object.
注意:我的ItemIndexRoute也会重定向,以便在其插座中显示第一张图片:
App.ItemIndexRoute = Em.Route.extend({
model: function(params) {
return App.Item.find(params.item_id);
},
redirect: function(params) {
var image = App.Image.find(params.item_id).get('firstObject');
this.transitionTo('images');
}
});
如果我删除ItemIndexRoute上的重定向,那么我会在/ items处获得以下内容:
警告:直接父路线('a')未进入主插座,可能不会出现默认的'into'选项('p') ember.js:349转换为'items.item.index'