Ionic-framework: [attr.name] not working properly for ion-icon

Created on 11 Dec 2016  路  3Comments  路  Source: ionic-team/ionic-framework

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

Most helpful comment

just use

<ion-icon [name]="notification.type == 'newMessage' ? 'text' : 'calendar' "></ion-icon>

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daveshirman picture daveshirman  路  3Comments

GeorgeAnanthSoosai picture GeorgeAnanthSoosai  路  3Comments

fdnhkj picture fdnhkj  路  3Comments

MrBokeh picture MrBokeh  路  3Comments

alexbainbridge picture alexbainbridge  路  3Comments