Ionic Uncaught (in promise): invalid link

后端 未结 5 783
再見小時候
再見小時候 2021-01-12 01:58

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

相关标签:
5条回答
  • 2021-01-12 02:26

    Just add @IonicPage() before @component in ts file for example:

    @IonicPage() @Component({ selector: 'page-wall', templateUrl: 'wall.html', })

    0 讨论(0)
  • 2021-01-12 02:26

    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

    0 讨论(0)
  • 2021-01-12 02:29

    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!!!

    0 讨论(0)
  • 2021-01-12 02:43

    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

    0 讨论(0)
  • 2021-01-12 02:44

    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');

    0 讨论(0)
提交回复
热议问题