Ionic version: (check one with "x")
[ ] 1.x
[X] 2.x
I'm submitting a ... (check one with "x")
[X] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
When trying to set the icon name depending on a variable value the icon doesn't show up at all.
When I use the code showed below the icon doesn't show up, but when I inspect the HTML I can see that the icon is there, with the right name attribute.
Expected behavior:
The icon should appear normally.
Live preview - http://plnkr.co/edit/8H9lu2uxXMattywGEBlw?p=preview
Related code:
<ion-list>
<ion-item *ngFor="let notification of notifications" text-wrap item-left>
<ion-badge color="danger" item-right>
<ion-icon [attr.name]="notification.type == 'newMessage' ? 'text' : 'calendar' "></ion-icon>
</ion-badge>
<p>Some text in here</p>
</ion-item>
</ion-list>
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Cordova CLI: 6.4.0
Gulp version: CLI version 1.2.2
Gulp local:
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
OS: Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS
Node Version: v6.9.2
just use
<ion-icon [name]="notification.type == 'newMessage' ? 'text' : 'calendar' "></ion-icon>
Thanks, that solved it!
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Most helpful comment
just use