ionic-framework: ERROR Error: Uncaught (in promise): nav controller was destroyed
Ionic version: (check one with “x”) [ ] 1.x [ ] 2.x [x] 3.x
I’m submitting a … (check one with “x”) [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior: I’m using lazy loading. If I set rootPage in ngOnInit, I’m getting following error. If I set rootPage at class level, it works. Please see code below. I have to close IonicErrorHandler screen every time because of this error.
Expected behavior: I shouldn’t get following error doesn’t matter when I’m setting rootPage.
Steps to reproduce:
Related code:
app.html
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
This works
@Component({
templateUrl: 'app.html'
})
export class MyApp implements OnInit {
rootPage: string = 'TabsPage'; // <---Setting rootPage here works perfectly
constructor(public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
public dbService: DatabaseService) {
}
}
This fails with below error
@Component({
templateUrl: 'app.html'
})
export class MyApp implements OnInit {
rootPage: string;
constructor(public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
public dbService: DatabaseService) {
}
async ngOnInit() {
this.rootPage = await this.dbService.getRootPage(); // <---Setting rootPage here gives error
}
}
ERROR
VM6490 main.js:1436 ERROR Error: Uncaught (in promise): nav controller was destroyed
at d (VM6472 polyfills.js:3)
at l (VM6472 polyfills.js:3)
at Object.reject (VM6472 polyfills.js:3)
at Tab.NavControllerBase._fireError (VM6490 main.js:47582)
at Tab.NavControllerBase._failed (VM6490 main.js:47561)
at VM6490 main.js:47625
at t.invoke (VM6472 polyfills.js:3)
at Object.onInvoke (VM6490 main.js:4477)
at t.invoke (VM6472 polyfills.js:3)
at n.run (VM6472 polyfills.js:3)
at VM6472 polyfills.js:3
at t.invokeTask (VM6472 polyfills.js:3)
at Object.onInvokeTask (VM6490 main.js:4468)
at t.invokeTask (VM6472 polyfills.js:3)
at n.runTask (VM6472 polyfills.js:3)
defaultErrorLogger @ VM6490 main.js:1436
ErrorHandler.handleError @ VM6490 main.js:1496
next @ VM6490 main.js:5106
schedulerFn @ VM6490 main.js:4180
SafeSubscriber.__tryOrUnsub @ VM6490 main.js:39973
SafeSubscriber.next @ VM6490 main.js:39922
Subscriber._next @ VM6490 main.js:39864
Subscriber.next @ VM6490 main.js:39828
Subject.next @ VM6490 main.js:60358
EventEmitter.emit @ VM6490 main.js:4166
NgZone.triggerError @ VM6490 main.js:4537
onHandleError @ VM6490 main.js:4498
t.handleError @ VM6472 polyfills.js:3
n.runGuarded @ VM6472 polyfills.js:3
(anonymous) @ VM6472 polyfills.js:3
a @ VM6472 polyfills.js:3
Other information:
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Your system information:
Cordova CLI: 6.5.0
Ionic Framework Version: 3.1.1
Ionic CLI Version: 2.2.3
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.3.6
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: macOS Sierra
Node Version: v7.3.0
Xcode version: Xcode 8.3.2 Build version 8E2002
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 3
- Comments: 24 (9 by maintainers)
@jgw9 Are you crazy? You closed this issue by stating that it is a duplicate of one which was not resolved.
If you are not able to fix it. Please let it be in OPEN state and do not mark it as duplicate!
I am facing the same and looking for workaround.
I also have encountered this problem. this is my component:
login() { this.userService.login(this.form.value) .then(() => this.navCtrl.setRoot(cfg.page.root)) .catch(e => console.log('login error', e)); }ERROR Error: Uncaught (in promise): nav controller was destroyed
I also often get this error but strangely it disappears after I refresh / reload the webpage.
funny though that the other issue got closed as a duplicate as well 🙈
@jgw96 any updates on this issue?
This is the way issue tracking works. There are always other professions you can try.