Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to concatenate string inside html document

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>
like image 411
Никола Спајић Avatar asked May 27 '17 09:05

Никола Спајић


People also ask

Can you concatenate string in HTML?

HTML is a markup language. No, it has no 'concatenation functionality'.

How do I concatenate a variable in HTML?

The easiest method to concatenate two strings is to use the template literals. Generally, programmers use the + operator to add two or more numbers, but when we use the + operator with the string variables, it simply merges the two strings.


1 Answers

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.

like image 149
Philipp Meissner Avatar answered Oct 21 '22 17:10

Philipp Meissner