您好,我在 Ember 中有一个异步模型(因为固定装置强制您使用 async:true),该模型在模板中不起作用( promise 可能未解决)。
此代码例如:
{{#each tag in imagepost.tags}}
<strong class="links-no-color"><a>{{tag}}</a></strong>
{{/each}}
生产:
<App.Tag:ember625:1> <App.Tag:ember626:2> <App.Tag:ember627:3>
Ember 不应该看到我访问标签并向标签端点发出请求吗?
我怎样才能手动告诉他解决这个问题?这不起作用(在组件中):
comments: function() {
this.get('imagepost.comments').then(function(val){ return val;});
}.property('imagepost'),
最佳答案
这有效!但是您需要引用标签模型上的任何属性,而不仅仅是循环中的标签记录(我做了 tag.name)
{{#each tag in imagepost.tags}}
<strong class="links-no-color"><a>{{tag.name}}</a></strong>
{{/each}}
关于ember.js - 模板中的 Ember 数据异步模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24344944/