Ionic2 ionic-img-viewer抛出错误

时间:2017-01-25 16:10:33

标签: angular ionic2

我正在尝试在我的ionic2应用程序中使用 ionic-img-viewer ,我会遇到以下错误:

Runtime Error
Type ImageViewerDirective is part of the declarations of 2 modules: IonicImageViewerModule and AppModule! Please consider moving ImageViewerDirective to a higher module that imports IonicImageViewerModule and AppModule. You can also create a new NgModule that exports and includes ImageViewerDirective then import that NgModule in IonicImageViewerModule and AppModule. 

我的app.module.ts:

import { IonicImageViewerModule, ImageViewerDirective } from 'ionic-img-viewer';
@NgModule({
    imports: [
    IonicModule.forRoot(MyApp),
    IonicImageViewerModule,
    TranslateModule.forRoot({
      provide: TranslateLoader,
      useFactory: (createTranslateLoader),
      deps: [Http]
    })
  ],
  declarations: [
    MyApp,
    Home,
    Tutor,
    CameraTest,
    ImageDrawTextDirective,
    ImageViewerDirective
  ],

  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    Home,
    Tutor,
    CameraTest
  ],
  providers: [{provide: ErrorHandler, useClass: IonicErrorHandler, }]
})

export class AppModule {}

在我的组件中,我将其导入为:

import { ImageViewerDirective } from 'ionic-img-viewer';

然后在我的HTML中:

<img [src]="cigar_anatomy" alt="anatomy" imageViewer >

我做错了什么?

0 个答案:

没有答案