模块导入的意外指令,请添加@ngmodule批注

时间:2019-06-23 11:29:57

标签: angular typescript ionic-framework ionic3

尝试ionic cordova build android --prod --release来准备要部署的应用程序。 我遇到了尝试修复的错误。 最初收到的错误是

  

在其中键入SecondPage   longlocation / second / second.ts是   的一部分   2个模块的声明:longlocation / src / app / app.module.ts中的AppModule和               在longlocation / src / pages / second / second.module.ts中的SecondPageModule!   请               考虑将longlocation / src / pages / second / second.ts中的SecondPage移至   更高               在longlocation / src / app / app.module.ts中导入AppModule的模块,并               在longlocation / src / pages / second / second.module.ts中的SecondPageModule。

我从

中删除了提到的组件
  

声明

由另一个stackoverflow答案指示。

现在我收到另一个错误提示

  

模块“ AppModule”导入了意外的指令“ SecondPage”。   请添加@ngmodule批注

我的代码是

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { SecondPage } from '../pages/second/second';
import { SendtextPage } from '../pages/sendtext/sendtext';

import { SMS } from '@ionic-native/sms';

import { HttpClientModule } from '@angular/common/http';

@NgModule({
  declarations: [
    MyApp,
    HomePage,
    //SecondPage,
    //SendtextPage
  ],
  imports: [
    BrowserModule,
    HttpClientModule,
      SecondPage,
      SendtextPage,
    IonicModule.forRoot(MyApp)

  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    SecondPage,
    SendtextPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    SMS,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}
  

Ionic框架:3.9.2 Ionic应用程序脚本:3.2.1 Angular Core:   5.2.11 Angular Compiler CLI:5.2.11节点:10.6.0

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

编辑您的second.module.ts并从声明中删除SecondPage 并按以下方式将其保留在app.module.ts上:

this.navCtrl.push(SecondPage);

如果要使用:导航到它,

 this.navCtrl.push("SecondPage");

您也应该将其从app.module.ts中删除

相关问题