content.name返回空以进行收集 [英] content.name returns empty for collection
问题描述
我从ember.js开始,遇到了在ember.js文档中尝试问题的麻烦( 结果: 因此,它可以有效地遍历对象,但无法返回每个对象的名称值.为什么是这样?文档是否过时了?有没有更好的方法来达到预期的结果(逐项重复)?感谢您的回答. 我认为您使用的是ember-latest或1.0-pre,在这种情况下,您必须在 那只蜜蜂说,该文档不是最新的.您可以发布带有修复程序的拉动请求吗? I'm starting with ember.js and ran into trouble trying out things in the ember.js docs (http://docs.emberjs.com/symbols/Handlebars.helpers.html#.collection). This application code: with this template code: Results in this: So, it effectively iterates through the objects, but fails to return the name values for each. Why is this? Are the docs outdated, perhaps? Is there a better way to achieve the desired result (iterating through the items)? Thanks for your answers. I think you are using ember-latest, or 1.0-pre, in this case, you have to prefix That beeing said, the documentation is not up to date. Could you post a pull request with the fix? 这篇关于content.name返回空以进行收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
< div id ="ember122" class ="ember-view">< div id ="ember142" class ="ember-view">< div id ="ember149" class ="ember-view">你好< script id ="metamorph-0-start" type ="text/x-placeholder"></script>< script id ="metamorph-0-end" type ="text/x-placeholder"></script></div>< div id ="ember150" class ="ember-view">你好< script id ="metamorph-1-start" type ="text/x-placeholder"></script>< script id ="metamorph-1-end" type ="text/x-placeholder"></script></div>< div id ="ember151" class ="ember-view">你好< script id ="metamorph-2-start" type ="text/x-placeholder"></script>< script id ="metamorph-2-end" type ="text/x-placeholder"></script></div></div></div>
content.name
前面加上前缀 view
.从1.0之前的版本开始,上下文的检索发生了变化.请参阅: Ember.js:车把什么都不显示以获取进一步的解释./p>App = Ember.Application.create()
App.items = [
Ember.Object.create({name: 'Dave'}),
Ember.Object.create({name: 'Mary'}),
Ember.Object.create({name: 'Sara'})
]
{{#collection contentBinding="App.items"}}
Hi {{content.name}}
{{/collection}}
<div id="ember122" class="ember-view">
<div id="ember142" class="ember-view">
<div id="ember149" class="ember-view"> Hi
<script id="metamorph-0-start" type="text/x-placeholder">
</script>
<script id="metamorph-0-end" type="text/x-placeholder">
</script>
</div>
<div id="ember150" class="ember-view"> Hi
<script id="metamorph-1-start" type="text/x-placeholder">
</script>
<script id="metamorph-1-end" type="text/x-placeholder">
</script>
</div>
<div id="ember151" class="ember-view"> Hi
<script id="metamorph-2-start" type="text/x-placeholder">
</script>
<script id="metamorph-2-end" type="text/x-placeholder">
</script>
</div>
</div>
</div>
content.name
with view
. Since 1.0 pre, the retrieval of the context change. see: Ember.js: Handlebars displays nothing for furhter explanations.