Error : has a @IonicPage decorator, but it does not have a corresponding “NgModule” [duplicate]

醉酒当歌 提交于 2019-12-11 09:13:20

问题


C:\wamp\www\Ionic4\ionic3-angular4\src\pages\home\home.ts has a @IonicPage decorator, but it does not have a corresponding "NgModule" at C:\wamp\www\Ionic4\ionic3-angular4\src\pages\home\home.module.ts

home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { IonicPage } from 'ionic-angular';

@IonicPage({
     name: 'home'
})
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController) {

  }

}

home.module.ts

import { NgModule } from '@angular/core';
import { HomePage} from './home';
import { IonicPageModule } from 'ionic-angular';

@NgModule({
  declarations: [HomePage],
  imports: [IonicPageModule.forChild(HomePage)],
  entryComponents: [HomePage]

})
export class HomePageModule { }

回答1:


Your home.module.ts should be like below.You have missed some properties on @NgModule.You don't need to use entryComponents: [HomePage] inside your module.ts file.So try as shown below.

Note: + The key issue is the missing exports array.

home.module.ts

import { NgModule } from '@angular/core';
import { HomePage} from './home';
import { IonicPageModule } from 'ionic-angular';

@NgModule({
  declarations: [
    HomePage
  ],
  imports: [
    IonicPageModule.forChild(HomePage),
  ],
  exports: [
    HomePage
  ]
})
export class HomePageModule { }


来源:https://stackoverflow.com/questions/45518383/error-has-a-ionicpage-decorator-but-it-does-not-have-a-corresponding-ngmodu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!