Ionic2 - check if page is active

IONIC 2 & 3: Because of the uglification you cannot use pagename for production.

I check the active page by looking if the last page on the controller stack is of the instance of the page:

import { NavController } from 'ionic-angular';
import { myPage } from '../../pages/my/my';
...
constructor(public navCtrl: NavController) {}
...
let active = this.navCtrl.last().instance instanceof MyPage;

IONIC 4: Routing is changed. This looks like the new way:

import { Router } from '@angular/router';
...
constructor(public router: Router) {}
...
let active =  this.router.isActive('mypage', false)

Tags:

Angular

Ionic2