【发布时间】:2014-10-18 22:41:23
【问题描述】:
如何在 Ember 应用程序中迭代车把模板中的对象?
<div class="alert alert-danger">
<strong>We couldn't create this Company.</strong>
{{#each errors}
<p>{{this}}</p>
{{/each}}
</div>
console.log(response.errors);
Object {0: "Name can't be blank", 1: "Zip code can't be blank", 2: "Company type can't be blank", 3: "Address line can't be blank", 4: "Country can't be blank", 5: "State can't be blank"}
我在控制台中得到的错误是:
未捕获的错误:断言失败:#each 循环的值必须 成为一个数组。您通过了{0:姓名不能为空,1:邮政编码不能为 空白,2:公司类型不能为空,3:地址行不能为空, 4:国家不能为空,5:国家不能为空}
有什么建议吗?
【问题讨论】:
-
将错误重构为数组
-
你看我下面的回答了吗?您是否愿意详细说明它如何满足或不满足您的要求,因为问题仍然悬而未决?
标签: loops object ember.js each handlebars.js