Reputation: 53
I'm doing an ionic example: simple Notes app which let user add Note and display notes. When navigate from ionic page back to homepage I get this error:
This is the simple app:
When press ADD from homepage, New Ionic page is displayed.
After user type Title and Content, then press Add one note will be added to the list and then app navigate back to homepage. What I did is: - Create add-note page. - In add-note.ts, I navigate back to homepage like this:
addNote(note: Note){
this.noteListService.addNote(note).then(ref => {
this.navCtrl.setRoot('HomePage');
});
}
I did tried this.navCtrl.popToRoot() but it not work.
Anybody know the reason?
Upvotes: 0
Views: 145
Reputation: 53
After a while, I fix this problem by: - Import HomePage:
import { HomePage } from '../../pages/home/home'
this.navCtrl.setRoot(HomePage);
Upvotes: 0
Reputation: 1523
the flow should something like this. The app starts and the HomePage
is loaded and displayed as root
. When you navigate to another page you do this.navCtrl.push(otherPage)
. When you want to go back to the root you do this.navCtrl.pop()
see Ionic NavController for further details.
Upvotes: 0