I have probably a problem with this.nav.push
in Ionic. I have done a login/registration page but when I login, I get this error message. I have to add some code
Just add @IonicPage() before @component in ts file for example:
@IonicPage() @Component({ selector: 'page-wall', templateUrl: 'wall.html', })
I copied login example. The error is similar.
Check points for HomePage : (1) check whether home.module.ts is (2) check @IonicPage() before '@Component' in home.ts (2) remove HomePage from declaration/entryComponents in app.module.ts when facing open-error
Turn out It work like a charm once you restart the server again, Took me hours to fix,If issue is not resolved by @IonicPage()
, just restart your server. ie ionic serve
.
Happy coding!!!
what you need to do is to add @IonicPage() before '@Component' and import 'IonicPage' like this :
import {NavController, IonicPage} from 'ionic-angular';
then you need to create a module for the homepage i.e in the home directory , create home.module.ts with the following contents
import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { HomePage } from './home';
@NgModule({
declarations: [
HomePage
],
imports: [
IonicPageModule.forChild(HomePage),
],
exports: [
HomePage
]
})
export class HomePageModule {}
and reload the project
The only problem in your code is when you write
this.nav.push('HomePage');
remove the ' ' quotes when calling any page, and write like this.
this.nav.push(HomePage);
without quotes.
Above answer is for ionic2, in ionic3 there is lazy loading where you call like this
this.nav.push('HomePage');