我正在开发一个ionic 3应用程序,在该应用程序中我们已从CLI创建了自定义可扩展组件,但在控制台中出现以下错误:
模块'AppModule'导入了意外的指令'ExpandableComponent'。请添加@NgModule批注。
我已经创建了ExpandableComponent并将其导入到我们的app.module.ts fil。中,位于我们的bapp.module.ts文件之下
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { ServiceProvider } from '../providers/service';
import { HttpClientModule } from '@angular/common/http'
import { IonicStorageModule } from '@ionic/storage';
import { ExpandableComponent } from '../components/expandable/expandable';
@NgModule({
declarations: [
MyApp
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpClientModule,
ExpandableComponent,
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
ExpandableComponent
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
ServiceProvider
]
})
export class AppModule {}
<ion-list>
<button (click)="expandItem(item)" *ngFor="let item of itemList">
<ion-thumbnail item-start>
<img src="http://placehold.it/100">
</ion-thumbnail>
<h2>My Neighbor Totoro</h2>
<p>Hayao Miyazaki • 1988</p>
<expandable [expandHeight]="itemExpandHeight" [expanded]="item.expanded">
Hello people
</expandable>
</button>
</ion-list>
我试图从模块以及入口组件更改可扩展组件的位置,但无法正常工作。请告诉我任何人我的代码有什么问题吗?