0
votes

I am using ionic 3.10.3 my root page is loginPage then after user validation its redirect to HomeViewPage by as bellow

this.nav.setRoot(HomeViewPage);

no problem to now but in the HomeViewPage If the user click add button it must be redirect to NewItemPage I tried to use

    this.nav.setRoot(NewItemPage, {itemID: _id, isNew: _isNew});

and

    this.nav.push(NewItemPage, {itemID: _id, isNew: _isNew});

bellow is the new function

newItem(){
this.events.publish('apps:viewItem', this.handlerService.getNewID(), "1");
}

and this is the code in app.component.ts the receive event

this.events.subscribe('apps:viewItem', (_id, _isNew) => {
this.menu.close();
this.rootPage = NewItemPage;
this.nav.setRoot(NewItemPage, {itemID: _id, isNew: _isNew}).then(()=>{
  this.nav.popToRoot();
}).catch(err=>{
  alert("NewItemPage Error : " + err.toString());
});

});

but still in the HomeViewPage even i clicked the button many times but when I click back button it return to NewItemPage but now data exists.

Any help

1
please post a bit of code from homeViewPage.tsSonicd300
why dont you navigate to newItemPage from within homeViewPage.ts?Sonicd300
I got the same resultFatehi_Alqadasi
thanks for your help @Sonicd300 i solved itFatehi_Alqadasi

1 Answers

0
votes

The problem was in NewItemPage the I use a null object property

<ion-item>
  <ion-label>Activity Type</ion-label>
  <ion-select [(ngModel)]="handlerService.dataService.item.activityType">
    <ion-option *ngFor="let g of handlerService.dataService.activityTypes" value="{{g.id}}">{{ g.name }}</ion-option>
  </ion-select>
</ion-item>

handlerService.dataService.item is an object that must be initialized