【发布时间】:2013-12-25 10:02:17
【问题描述】:
使用 Ember.js v1.2.0,我正在尝试将侧边栏模板呈现到命名插座中。根据当前路线,模板可能会有所不同。我正在努力想出“Ember”的方式来做到这一点。
这是我目前所掌握的要点:
app/templates/application.hbs
{{outlet sidebar}}
app/routes/application.js
var ApplicationRoute = Ember.Route.extend({
renderTemplate: function(controller, model) {
var sidebar = controller.get('sidebar') || 'application';
this._super();
this.render('sidebar/' + sidebar, {
into: 'application',
outlet: 'sidebar'
});
}
});
app/routes/docs.js
var DocsRoute = Ember.Route.extend({
renderTemplate: function(controller, model) {
this.controllerFor('application').set('sidebar', 'docs');
this.render();
}
});
这并不真正起作用,而且感觉不是很Ember-ish。帮忙?
【问题讨论】:
标签: javascript ember.js