我发现了这个jsFiddle,我现在想知道在IndexRoute
和match('/contributor/:contributor_id')
的所有子路由中显示贡献者列表的最佳方法是什么1}}使用来自Ember.js的新v2路由器。
我遇到的问题是
App.IndexRoute = Ember.Route.extend({
model: function() {
return App.Contributor.find();
}
});
仅获取指定/
路由上的数据。
直接导航到/#/contributor/[some_id]
时,IndexRoute
的数据无法加载,用户首先必须导航到/
才能看到贡献者列表。< / p>
我唯一可能的解决方案是在ContributorsView
模板中调用application
。同时我不知道如何用数据填充此视图,因为视图没有路由所具有的model
属性。
答案 0 :(得分:2)
我还不熟悉新的路由器实现,但从设计的角度来看,我会为路由使用不同的结构,例如添加一个可从索引访问的贡献者路由,也许直接重定向对贡献者。 然后你总是显示贡献者,当点击其中一个时,你可以看到细节。一种主/细节块。
路由器地图:
App.Router.map(function(match){
match('/').to('home');
match('/about').to('about');
match('/contributors').to('contributors', function(match){
match('/').to('contributorsIndex');
match('/:contributor_id').to('contributor', function(match){
match('/').to('contributorIndex');
match('/details').to('contributorDetail');
match('/repos').to('contributorRepos');
});
});
});
以下是我要做的事情:http://jsfiddle.net/JLHuG/21/它对你有用吗?