我已经在我的
应用程序路径
App.ApplicationRoute = App.AuthenticatedRoute.extend({
model: function() {
return Ember.RSVP.hash({
projects: this.store.find('project'),
departments: this.store.find('department'),
});
},
setupController: function(controller, model) {
controller.set('model', model);
}
});
应用程序控制器
App.ApplicationController = Ember.ObjectController.extend({
all_projects: Ember.computed.alias('model.projects'),
all_departments: Ember.computed.alias('model.departments'),
});
然后在我的模板中有这个
<div class="col-xs-1" style="padding:0">
{{view Ember.Select class="form-control cover-input" content=all_projects value=create_project}}
</div>
{{view Ember.Select class="form-control half-input" content=all_departments optionValuePath="content.id" optionLabelPath="content.department_name" value=create_department}}
但是选择框中没有显示任何内容。我还试过循环遍历属性,像这样
{{#each all_departments}} {{department_name}} {{/each}}
也没有显示任何东西
您的模型别名all_projects和all_departments将是一个数组对象。所以你应该为你的ApplicationController扩展ArrayController而不是扩展ObjectController。
希望这将解决加载烬的问题。选择视图。
下面给出了一个使用Ember的多模型的基本示例。选择view来呈现两个模型。
JSBIN凌