本文介绍了如何在HTML文档中连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在HTML属性中连接字符串.我正在使用角度控制器,并且在用HTML写一些数组的部分(下面的代码)中,我想输入的输入标签名称为"kolicina" + {{idhrana}}是对象jelo的属性.
How can I concatenate string in HTML Attribute. I am using angular controller and in the part where I write some array in HTML (Code is below), I want to give input tag name that is "kolicina" + {{idhrana}} witch is attribute of object jelo.
<div class = "rezultat" ng-repeat="jelo in hrana | filter:pretrazi_namirnice">
<div> {{jelo.naziv}} </div>
<div> {{jelo.energijaKCal}}</div>
<div> {{jelo.proteini}}</div>
<div> {{jelo.uglj_hidrati}}</div>
<div> {{jelo.masti}}</div>
<div><input type=text nama="kolicina"+{{idhrana}}></div>
<div><input type="button" ng-click = 'dodaj(jelo)' value="Dodaj"></div>
</div>
推荐答案
您可以这样做:
<input type=text name="kolicina{{idhrana}}"></div>
无需显式连接它.另外,我认为您在 nam
和 name
属性之间有错别字.
No need to explicitely concatenate it.Also, I think you had a typo with nama
versus the name
-attribute.
这篇关于如何在HTML文档中连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!