Patrioticcow Patrioticcow - 2 months ago 50
Javascript Question

How to watch for ngSwitchCase in Ionic 2 / Angular 2?

I have a simple

ngSwitchCase
scenario

I want to watch for and get notified of
ngSwitchCase
in the controller, Basically when i switch between tabs.

Any ideas?

Answer

Looking at the docs I see there is an output event called ionChange. You could hook into that:

<ion-segment [(ngModel)]="selectedTab" (ionChange)="selectedTabChanged($event)">
    ...
<ion-segment>

And in your component you then have your method:

selectedTabChanged($event): void {
    // do something here
}
Comments