Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ionic framework 如何通过在ionic2中扩展BaseInput来创建自定义表单组件_Ionic Framework_Ionic2_Ionic3 - Fatal编程技术网

Ionic framework 如何通过在ionic2中扩展BaseInput来创建自定义表单组件

Ionic framework 如何通过在ionic2中扩展BaseInput来创建自定义表单组件,ionic-framework,ionic2,ionic3,Ionic Framework,Ionic2,Ionic3,我想通过扩展BaseInput在ionic2中创建一个自定义表单输入组件。但是它没有被渲染,我在DOM上找不到它 import { Component, ElementRef, OnDestroy, Optional, Renderer, ViewEncapsulation } from "@angular/core"; import { Config, Form, Item } from "ionic-angular"; import { BaseInput } from "ionic-an

我想通过扩展
BaseInput
在ionic2中创建一个自定义表单输入组件。但是它没有被渲染,我在DOM上找不到它

import { Component, ElementRef, OnDestroy, Optional, Renderer, 
ViewEncapsulation } from "@angular/core";
import { Config, Form, Item } from "ionic-angular";
import { BaseInput } from "ionic-angular/util/base-input";
import { NG_VALUE_ACCESSOR } from "@angular/forms";

@Component({
  selector: 'my-checkbox',
  template:
  '<p>aaaaa</p>',
  host: {
    '[class.checkbox-disabled]': '_disabled'
  },
  providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: MyCheckboxComponent, multi: true } ],
  encapsulation: ViewEncapsulation.None,
})
export class MyCheckboxComponent extends BaseInput<any> implements OnDestroy {

  constructor(form: Form, config: Config, elementRef: ElementRef, renderer: Renderer, @Optional() item: Item) {
    super(config, elementRef, renderer, 'my-checkbox', [], form, item, null);
  }

}
import{Component,ElementRef,OnDestroy,可选,渲染器,
来自“@angular/core”的视图封装};
从“离子角度”导入{Config,Form,Item};
从“ionic angular/util/base input”导入{BaseInput};
从“@angular/forms”导入{NG_VALUE_ACCESSOR}”;
@组成部分({
选择器:“我的复选框”,
模板:
“aaaaa

”, 主持人:{ “[class.checkbox已禁用]”:“\u已禁用” }, 提供者:[{provide:NG_VALUE_访问器,useExisting:MyCheckboxComponent,multi:true}], 封装:视图封装。无, }) 导出类MyCheckboxComponent扩展BaseInput实现OnDestroy{ 构造函数(form:form,config:config,elementRef:elementRef,renderer:renderer,@Optional()项:项){ super(配置,elementRef,呈现器,'我的复选框',[],表单,项,null); } }

代码是从
src/component/checkbox/checkbox.ts复制的,并做了一些修改。

我也遇到了同样的问题。我的组件未在父元素中获得渲染。我通过添加
项目内容
指令修复了它


标签

我也有同样的问题。我的组件未在父元素中获得渲染。我通过添加
项目内容
指令修复了它


标签