Mike Wells
Mike Wells

Reputation: 425

Ionic turn button click off in ngFor loop

I am in Ionic 3 and have a loop in my HTML:

  <button ion-button *ngFor="let button of menuItems" (click)="presentPopover($event,button.children)">
    <ion-icon name="wind-flag"><div class="active">100%</div></ion-icon>
  </button>

I'd like to turn off the click handler if my 'button.children' array count is zero. I have had a good look around and as this angular approach is new to me, I'm having not a lot of luck. Thanks in advance.

Furthering this id like it to show me the array node button.link, grrr I cant see how!! I wrap it in {{ }} and it errors.

button.children.length > 0 ? presentPopover($event,button.children) : {{ button.link }}

Upvotes: 1

Views: 328

Answers (1)

Vivek Doshi
Vivek Doshi

Reputation: 58523

You can do it like :

(click)="button.children.length > 0 ? presentPopover($event,button.children) : false"

Upvotes: 1

Related Questions