Use a variable as an Attribute in Tags

Is it possible to use a variable as an attribute in a tag?

For example, I want to have VAR to change the ion-icon attribute.

  <ion-item>
    <ion-icon name="leaf" VAR></ion-icon>
      Herbology
    <ion-icon name="rose" item-right></ion-icon>
  </ion-item>

yes it is possible,
how you want to do is up to you,
create a var as a directive or a vairble in ts and use it here
or else …
what you want do? explain a little bit more

Actually I want to change the color of components by coding and I use primary, secondary, ... as colors. So how can I change this parameters in a tag.
For example, I wanna click on an icon to change its color, just global colors that I defined as variables. I don’t want to use [style] to change the color.

<ion-icon name="heart" ColorVar></ion-icon>

hopefully this is what you think

Angular 2 Directive and attributes

or else you need create a service and inject that service to all the components let that colorservice take care of your colors

This will be possible in beta.12, for details see the following issue:

1 Like