Ionic2 ngOnInit,ionViewWillEnter和nav-push

时间:2017-04-11 09:49:53

标签: ionic2

我有这种情况,[nav-push]ion-item导航到详细信息页面,在详细信息页面ionViewWillEnter上不会被调用,而ngOnInit会这样做。

//ion-item on list page...
<button ion-item detail-push
          *ngFor="let recipe of recipes"
          [navPush]="recipeEditPage"
          [navParams]="{recipe:recipe}">
        <h2>{{recipe.title}}</h2>
</button>

//details page, ionWillEnter doesn't fire, white ngOnInit does.
  ngOnInit(){
    if(this.navParams.data.recipe){
      this._mode = RecipeEditPage.Modes.EDIT;
      this._recipe=this.navParams.data.recipe;
    }
    else
      this._recipe = this.recipeSrv.getNewRecipe();
  }

谢谢! F。

0 个答案:

没有答案