Monday, May 20, 2024
113
rated 0 times [  117] [ 4]  / answers: 1 / hits: 33187  / 8 Years ago, thu, april 7, 2016, 12:00:00

in Angular 2 we have several way to create property bindings in templates.
I could do something like this:



<li *ngFor=#course of courses; #i = index id=someselector-{{i}}>{{course}}</li>


Is it possible to obtain the same result using the square brakets syntax?



<li *ngFor=#course of courses; #i = index [id]=someselector-i>{{course}}</li>
^^^^^^^
how create string concatenation?


Thanks,
G.


More From » angular2-template

 Answers
1

I found out that you can use this kind of syntax using square brackets:



<li *ngFor=#course of courses; #i = index [id]='someselector-'+i>{{course}}</li>


For more information, please have a look to this interesting article from Pascal Precht: http://blog.thoughtram.io/angular/2015/08/11/angular-2-template-syntax-demystified-part-1.html


[#62659] Tuesday, April 5, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
turnerf

Total Points: 620
Total Questions: 101
Total Answers: 109

Location: French Polynesia
Member since Tue, Jul 7, 2020
4 Years ago
turnerf questions
;