Just following the Ionic2 tutorial and exploring components and I have this doubt:
Is there a difference between…
<ion-icon [name]="myIcon"></ion-icon>
and
<ion-icon name="{{myIcon}}"></ion-icon>
?
it’s simply ionic2 style vs ionic1 ? or angularJs1 vs 2?
The difference is that x="{{y}}"
assigns the stringified value of y
(i.e. the result of y.toString()
), while [x]="y"
assigns the real (object) value of y
to x
. In both cases the value is updated automatically and if y
is of string
type value you might not notice any difference. In general, I would recommend [x]="y"
when binding to element properties.
6 Likes
Thank you.
I also found a good explanation here:
1 Like
Thanks for the link, quite interesting read indeed!