我的项目是使用 ember-cli 和 ES6 导入方法的 ember.js。
这个问题是关于new
将子资源的路由渲染dataset
到应用程序{{ outlet 'sidebar' }}
中,而数据集(显示)上的其他路由渲染到{{ outlet 'main' }}
应用程序.hbs
<div class="col-xs-8">
Outlet Main
{{liquid-outlet "main"}}
</div>
<div class="col-xs-4">
Outlet Sidebar
{{liquid-outlet "sidebar"}}
</div>
路由器.js
this.resource('organizations', function() {
this.route('new');
this.resource('organization', { path: '/:organization_id' }, function() {
this.route('edit');
this.resource('datasets', function() {
this.route('new');
this.resource('dataset', { path: '/:dataset_id' }, function() {
this.route('edit');
});
});
});
});
路线/组织.js:
import Ember from 'ember';
export default Ember.Route.extend({
renderTemplate: function() {
//render into application so organizations template doesn't show
this.render('organization', {
into: 'application',
outlet: 'main',
controller: 'organization'
});
// **** Not working but roughly what I want to do
this.render('organization.datasets.new', {
into: 'application',
outlet: 'sidebar',
controller: 'organization.datasets.new'
});
// ******
}
});
目前我在尝试此代码时收到此错误:
Error while processing route: types.index You passed `controller: 'organization.datasets.new'` into the `render` method, but no such controller could be found. Error: You passed `controller: 'organization.datasets.new'` into the `render` method, but no such controller could be found.
我的理解是,任何子资源路由都应该在父路由中确定。真的?如何让 ember 识别控制器?我猜我的语法是错误的......感谢您的帮助。