EmberJS-如何从{{each}}类型函数之外的模型中打印值 [英] EmberJS - How to print values from Model outside of {{each}} type functions
问题描述
我的模型(medid)已成功加载到模板(medid.hbs)上,但是当我尝试将记录中的值作为文本放入时,它不会呈现任何内容。
My model (medid) is successfully loaded on my template (medid.hbs) but when I try to put a value from the record in as text it doesn't render anything.
在其他模板中,我从模型中渲染的所有内容均在使用{{each}}帮助器进行迭代的表中。在这里,我使用了{{model.id}}来填充表行。
In other templates everything I rendered from the model was in a table iterated on with an {{each}} helper. Here I used {{model.id}} to populate the table rows.
我假设我可以使用类似你好,我的名字是{{model.id }},但这是行不通的。我可能缺少明显的东西
I assumed that I could just use something like 'Hello my name is {{model.id}} but that doesn't work. I'm probably missing something obvious
如何访问我的模型数据以在手把助手之外进行打印?
How do I access my model data for printing outside of a handlebars helper?
推荐答案
要从数组中检索第一项,可以使用 firstObject 。因此您可以像 {{model.firstObject.id}}
To retrieve the first item from the array you can use firstObject. so in your case you can access it like {{model.firstObject.id}}
这篇关于EmberJS-如何从{{each}}类型函数之外的模型中打印值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!