离子3角包括一个成分到另一个

时间:2017-09-18 23:01:55

标签: angular ionic3

所以我创建了一个组件nanme'fa-lov',如下所示:components.module.ts

@NgModule({
    declarations: [
      FaLovComponent
    ],
    imports: [
      IonicModule
    ],
    exports: [
      FaLovComponent
    ]
})
export class ComponentsModule {}

我有一个早期的popover页面,在app.modules.ts中如下所示 从'../ components / edit-opty-popover / edit-opty-popover'中导入{EditOptyPopoverComponent}

@NgModule({
  declarations: [
    MyApp,
    ListPage,
    EditOptyPopoverComponent,
  ],
  imports: [
    BrowserModule,
    HttpModule,
    IonicModule.forRoot(MyApp),
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    EditOptyPopoverComponent,
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

EditOptyPopover.html将组件包含为 <fa-lov [data]="somedata"></fa-lov>

然而,这失败并出现错误:

Unhandled Promise rejection: Template parse errors:
Can't bind to 'data' since it isn't a known property of 'fa-lov'.
1. If 'fa-lov' is an Angular component and it has 'data' input, then verify that it is part of this module.
2. If 'fa-lov' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress t

1 个答案:

答案 0 :(得分:1)

ComponentsModule 添加到 app.module.ts

中的导入
@NgModule({
  declarations: [
    MyApp,
    ListPage,
    EditOptyPopoverComponent,
  ],
  imports: [
    BrowserModule,
    ComponentsModule, //<-- note this import here
    HttpModule,
    IonicModule.forRoot(MyApp),
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    EditOptyPopoverComponent,
  ],
  providers: [
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}