我想通过扩展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);
}
}
代码是src/component/checkbox/checkbox.ts
的副本并进行一些更改。