他の<input type="checkbox" ... />
コンポーネントと同じようなフォームで使用できるSwitcheryスタイルのカスタムチェックボックスコンポーネントを作成しようとしています。Switcheryでスタイル指定されたカスタムチェックボックス入力コンポーネント
私が今持っているコードは、スタイリングの面倒を見る:
import {Component,ViewChild,AfterViewInit,Input} from 'angular2/core';
import switchery from 'switchery';
@Component({
selector: 'switchery-checkbox',
template: `<input #checkbox type="checkbox" class="js-switch"/>`,
})
export class SwitcheryComponent implements AfterViewInit {
@Input() options: Switchery.Options = {};
@ViewChild('checkbox') checkbox: any;
ngAfterViewInit() {
new switchery(this.checkbox.nativeElement,
this.options);
}
}
は、私は次のコードのようにテンプレートでそれを使用できるように追加することは何がありますか?理想的には、<input type="checkbox" />
のすべての機能を実装する必要があります。
<switchery-checkbox
[(ngModel)]="model.onOrOff"
ngControl="onOrOff"
[disabled]="disabledCondition"
... >
</switchery-checkbox>