Is there a way to execute code every time the page changes without adding an ngOnDestroy
method to every page in Ionic 2?
Instead of using Ionic 2 page lifecycle hooks like ionViewDidUnload
, is there a simpler solution by adding a single method to the main app class for the same effect?
I've noticed that Angular 2 Router events can be subscribed to, but how can this be translated for use in Ionic 2? I encountered an error when trying to import
{ Router } from '@angular/router;
.
TypeScript error: <path>/node_modules/@angular/router/src/common_router_providers.d.ts(9,55): Error TS2305: Module '"<path>/node_modules/@angular/core/index"' has no exported member 'NgModuleFactoryLoader'.
TypeScript error: <path>/node_modules/@angular/router/src/router.d.ts(14,39): Error TS2305: Module '"<path>/node_modules/@angular/core/index"' has no exported member 'NgModuleFactoryLoader'.
TypeScript error: <path>/node_modules/@angular/router/src/router_module.d.ts(9,10): Error TS2305: Module '"<path>/node_modules/@angular/core/index"' has no exported member 'ModuleWithProviders'.
Can the Nav
or NavController
service from ionic-angular be used instead for this purpose?