[英]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.