Ionic2 在Ionic 2版本3.0.1中,如何创建使用Ionic组件的自定义组件?

Ionic2 在Ionic 2版本3.0.1中,如何创建使用Ionic组件的自定义组件?,ionic2,components,Ionic2,Components,这个答案已经不起作用了 import {IONIC_DIRECTIVES} from 'ionic-angular' 这也不行。如何创建使用Ionic 2版本3.0.1中的Ionic组件的自定义组件 如果您在使用延迟加载后仍遇到此问题,您应该这样做: 将IonicModule添加到CustomComponentModule的“imports”参数 在自定义组件的模板中使用离子组件 将CustomComponentModule添加到要使用该组件的另一个组件模块(CustomComponentM

这个答案已经不起作用了

import {IONIC_DIRECTIVES} from 'ionic-angular' 

这也不行。如何创建使用Ionic 2版本3.0.1中的Ionic组件的自定义组件

如果您在使用延迟加载后仍遇到此问题,您应该这样做:

  • 将IonicModule添加到CustomComponentModule的“imports”参数
  • 在自定义组件的模板中使用离子组件
  • 将CustomComponentModule添加到要使用该组件的另一个组件模块(CustomComponentModule)的“imports”参数中 deletable.module.ts

    import { NgModule } from '@angular/core';
    import { DeletableItem } from './deletable';
    import { IonicModule } from 'ionic-angular';
    
    @NgModule({
      declarations: [
        DeletableItem
      ],
      imports: [
        IonicModule
      ],
      exports: [
        DeletableItem
      ]
    })
    export class DeletableModule {}
    
    import { NgModule } from '@angular/core';
    import { IonicPageModule } from 'ionic-angular';
    import { BillPage } from './bill';
    
    import { DeletableModule } from './../../components/deletable/deletable.module'
    
    @NgModule({
      declarations: [
        BillPage
      ],
      imports: [
        IonicPageModule.forChild(BillPage),
        DeletableModule
      ],
      exports: [
        BillPage
      ]
    })
    export class BillModule {}
    
    bill.html

    <ion-content padding>
      <ion-list>
        <ion-item *ngFor="let bill of bills" (click)="openEdit(bill)">
          <ion-label text-left>{{bill.name}}</ion-label>
          <ion-label text-right>{{bill.amount}}</ion-label>
          <deletableItem></deletableItem>
        </ion-item>
      </ion-list>
    </ion-content>
    

    这是我的工作。

    我也面临着类似的问题。你运气好吗?我通过从“ionic angular”导入
    import{IonicModule}成功地让它工作了并在自定义组件模块的导入部分添加此模块。不确定这是否是正确的方法,但它是有效的。