[英]How to print some property of a model from collection in Handlebars Template?
I am using a Collection of Models in Backbone application. 我在骨干网应用程序中使用模型集合。 The requirement is to print only first models attribute in the render function using handlebars template.
要求是使用把手模板仅在渲染功能中打印第一个模型属性。 Is there a way to get first element of collection in handlebars template?
有没有办法在把手模板中获取集合的第一个元素?
If you want only the first model of a collection, you can use collection.at(0);
如果只需要集合的第一个模型,则可以使用
collection.at(0);
. 。 Pass this into the handlebars template and then access it as you would normally within a handlebars template.
将其传递到车把模板中,然后像通常在车把模板中一样进行访问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.