我有以下路由设置:
this.resource('blog',function(){
this.resource('selectimage',{path:"selectimage/:returncontext"},function(){});
});
this.resource('post',{path:":post_id"},function(){
this.resource('selectimage',{path:"selectimage/:returncontext"},function(){});
});
Run Code Online (Sandbox Code Playgroud)
我期望的是,当导航到blog.selectimage和post.selectimage时,将使用相同的路由器,控制器和视图.不幸的是,似乎最后一个条目获胜.
导航到selectimage时,是否有可能在不离开父上下文(post/blog)的情况下实现这一点(显然我可以从base-selectimages-classes继承,但我希望有一些通用的ember方式来做到这一点. )
您不能为两个不同的路由使用相同的资源名称,因为Ember更多地依赖于命名约定.但是Ember提供了重用相同控制器和模板的方法
将帖子下的选择重命名为其他内容
this.resource('post',{path:":post_id"},function(){
this.resource('xxx',{path:"xxx/:returncontext"});
});
Run Code Online (Sandbox Code Playgroud)
在路由器中,您可以指定templateName并且controller必须重复使用.这样的东西应该可以重复使用
App.xxxRoute = Em.Route.extend({
controllerName: 'selectimage',
templateName: 'selectimage'
});
Run Code Online (Sandbox Code Playgroud)
示例演示
| 归档时间: |
|
| 查看次数: |
1064 次 |
| 最近记录: |