Hanzo
Hanzo

Reputation: 1899

*ngIf on Ionic 2 not work with binding

I'm Trying to hide/show elements of a ion-list depending of a boolean variable which is changed when a button is clicked.

The problem is that if I try with *ngIf="{{editMode}}" the ionic serve --lab shows blank screen on browser.

<ion-item-sliding *ngFor="let item of items" (click)="itemTapped($event, item)">
      <ion-item>

        <ion-icon item-left name="rose" *ngIf="{{editMode}}"></ion-icon>

        <ion-icon name="{{item.icon}}" item-left></ion-icon>
        {{item.title}}
        <div class="item-note" item-right>
          {{item.note}}
        </div>

      </ion-item>

And if i try with *ngIf="'editMode'" the result of click on button is nothing.

When I click on a nav bar button the boolen variable is modified to true/false.

What would be wrong?

Upvotes: 1

Views: 10840

Answers (1)

Suraj Rao
Suraj Rao

Reputation: 29614

Check here

You have to do *ngIf="editMode"

*ngIf="'editMode'" - Here you are just taking the string editMode which is truthy and button will not work.

Upvotes: 5

Related Questions