问题
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>
回答1:
You can do it like so:
<input type=text name="kolicina{{idhrana}}"></div>
No need to explicitely concatenate it.
Also, I think you had a typo with nama
versus the name
-attribute.
回答2:
http://plnkr.co/edit/uJcDZkrGNqzSibpgkTc9?p=preview
<input type=text name="kolicina {{idhrana}}">
working plnkr for understanding. hope this will help you.
来源:https://stackoverflow.com/questions/44215037/how-to-concatenate-string-inside-html-document