EmberJS - How to print values from Model outside of {{each}} type functions

青春壹個敷衍的年華 提交于 2019-12-11 15:39:51

问题


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.

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.

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?


回答1:


To retrieve the first item from the array you can use firstObject. so in your case you can access it like {{model.firstObject.id}}



来源:https://stackoverflow.com/questions/47409782/emberjs-how-to-print-values-from-model-outside-of-each-type-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!