简体   繁体   English

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

[英]unexpected directive imported by the module please add a @ngmodule annotation

Tried ionic cordova build android --prod --release in an attempt to prepare an app for deployment. 尝试使用ionic cordova build android --prod --release以尝试准备部署应用程序。 I came across an error which I attempted to fix. 我遇到了一个我试图解决的错误。 The error originally received was 最初收到的错误是

Type SecondPage in longlocation/second/second.ts is part of the declarations of 2 modules: AppModule in longlocation/src/app/app.module.ts and SecondPageModule in longlocation/src/pages/second/second.module.ts! 在longlocation / second / second.ts中键入SecondPage是2个模块声明的一部分:longlocation / src / app / app.module.ts中的AppModule和longlocation / src / pages / second / second.module.ts中的SecondPageModule! Please consider moving SecondPage in longlocation/src/pages/second/second.ts to a higher module that imports AppModule in longlocation/src/app/app.module.ts and SecondPageModule in longlocation/src/pages/second/second.module.ts. 请考虑将longlocation / src / pages / second / second.ts中的SecondPage移动到更高的模块,该模块导入longlocation / src / app / app.module.ts中的AppModule和longlocation / src / pages / second / second.module中的SecondPageModule。 TS。

I removed the mentioned components from 我删除了提到的组件

declarations 声明

as instructed by another stackoverflow answer. 按照另一个stackoverflow答案的指示。

Now I'm getting another error which says 现在我又收到了另一个错误

unexpected directive 'SecondPage' imported by the module 'AppModule'. 由'AppModule'模块导入的意外指令'SecondPage'。 Please add a @ngmodule annotation 请添加@ngmodule注释

My code is 我的代码是

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 Framework : 3.9.2 Ionic App Scripts : 3.2.1 Angular Core : 5.2.11 Angular Compiler CLI : 5.2.11 Node : 10.6.0 Ionic Framework:3.9.2 Ionic App脚本:3.2.1 Angular Core:5.2.11 Angular Compiler CLI:5.2.11节点:10.6.0

Any help is greatly appreciated. 任何帮助是极大的赞赏。

edit your second.module.ts and remove SecondPage from declarations and leave it on app.module.ts if you navigate to it like this : 编辑你的second.module.ts并从声明中删除SecondPage ,如果你像这样导航到app.module.ts

this.navCtrl.push(SecondPage);

if you'r navigate to it using : 如果你使用以下方式导航到它:

 this.navCtrl.push("SecondPage");

you should remove it from app.module.ts too 你应该从app.module.ts删除它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 由模块'AppModule'导入的意外指令'LoginComponent'。请添加@NgModule注释 - Unexpected directive 'LoginComponent' imported by the module 'AppModule'. Please add a @NgModule annotation 模块“AppModule”导入的意外指令“MatAutoCompleteTrigger”。 请添加@NgModule 注释 - Unexpected directive 'MatAutoCompleteTrigger' imported by the module 'AppModule'. Please add a @NgModule annotation 由模块'AppModule'导入的意外指令'MatSpinner'。 请添加@NgModule注释 - Unexpected directive 'MatSpinner' imported by the module 'AppModule'. Please add a @NgModule annotation 模块“DynamicTestModule”导入的意外指令“InformationComponent”。 请添加@NgModule 注解 - Unexpected directive 'InformationComponent' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation 由模块'AppModule'导入的意外指令'LoginPage'。 请添加@NgModule注释 - Unexpected directive 'LoginPage' imported by the module 'AppModule'. Please add a @NgModule annotation 未捕获的错误:模块“MyMaterialModule”导入的意外指令“angular-material”。 请添加@NgModule 注释。 角 5 - Uncaught Error: Unexpected directive 'angular-material' imported by the module 'MyMaterialModule'. Please add a @NgModule annotation. angular 5 未捕获的错误:模块'AppModule'导入了意外的指令'ProductsComponent'。 请添加@NgModule批注 - Uncaught Error: Unexpected directive 'ProductsComponent' imported by the module 'AppModule'. Please add a @NgModule annotation 我的问题是,模块“DashboardModule”导入的意外指令“BarChartComponent”。 请添加@NgModule 注释 - my question is, Unexpected directive 'BarChartComponent' imported by the module 'DashboardModule'. Please add a @NgModule annotation 错误:模块“ SharedModule”导入了意外的指令“ DashboardPage”。 请添加@NgModule批注 - Error: Unexpected directive 'DashboardPage' imported by the module 'SharedModule'. Please add a @NgModule annotation 失败:模块'DynamicTestModule'导入的意外指令'ContactDetailsComponent'。 请添加@NgModule注释 - Failed: Unexpected directive 'ContactDetailsComponent' imported by the module 'DynamicTestModule'. Please add a @NgModule annotation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM