Ionic2识别后视图

Ionic2 identify back view

如何在 ionic2 中识别 back/caller 视图?

我使用的是 ioni1

var backView:ionic.View = this.$ionicHistory.backView();
backView.stateName === 'app.view_I_want_to_test';

我正在考虑获取视图控制器,但不知道如何测试该视图控制器是否是我感兴趣的视图。

let lastView:ViewController = this.navController.getPrevious(this.navController.getActive());
then???

我找到了一个我不喜欢的解决方案,因为我必须进行肮脏的 "any" 转换才能访问用于比较的私有值,但以下代码可以完成工作:

onPageDidEnter() {
    // this.navController.last() strangely equals the view which entered
    let previousView:ViewController = this.navController.getPrevious(this.navController.last());

    if (previousView != null && (<any> previousView).instance instanceof MyPage) {
        doSomeStuffs();
   } else {
        doSomeOtherStuffs();
   }
}