我正在使用 XHR 请求从 api 到我的 Ember 应用程序中提取组列表。我正在尝试在 groups/index.hbs 模板中显示该列表。在模板中我有:
<h1>GROUPS INDEX</h1>
{{#each group in controller}}
{{ group.name }}
{{/each}}
{{outlet}}
我收到以下错误:
Uncaught Error: assertion failed: an Ember.CollectionView's content must implement Ember.Array. You passed <(generated groups.index controller):ember226>
对象数组加载正常。我只是无法在车把中显示它们。
我错过了什么?
编辑
groups_route.js.coffee
Mdm.GroupsRoute = Ember.Route.extend(model: ->
Mdm.Group.all()
)
router.js.coffee
Mdm.Router.map ->
@resource 'groups', ->
@resource 'group', path: ':group_id'
Mdm.Router.reopen
location: 'history'
group.js.coffee
Mdm.Group = Ember.Object.extend()
Mdm.Group.reopenClass
all: ->
Mdm.ajax(
url: Mdm.apiUrl('/groups')
).then (data) ->
console.log data
groups = []
for group in data.response
groups.addObject(Mdm.Group.create(group))
console.log(groups)
groups