mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-19 08:50:13 +01:00
feat(ba-checkbox): create checkbox component
This commit is contained in:
parent
bc7ea0e5b4
commit
e63812f011
6 changed files with 49 additions and 18 deletions
32
src/app/theme/components/baCheckbox/baCheckbox.component.ts
Normal file
32
src/app/theme/components/baCheckbox/baCheckbox.component.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import {Component, Provider, forwardRef, Input} from "@angular/core";
|
||||
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from "@angular/common";
|
||||
|
||||
const BA_CHECKBOX_CONTROL_VALUE_ACCESSOR = new Provider(
|
||||
NG_VALUE_ACCESSOR, {
|
||||
useExisting: forwardRef(() => BaCheckbox),
|
||||
multi: true
|
||||
});
|
||||
|
||||
@Component({
|
||||
selector: 'ba-checkbox',
|
||||
template: require('./baCheckbox.html'),
|
||||
providers: [BA_CHECKBOX_CONTROL_VALUE_ACCESSOR]
|
||||
})
|
||||
export class BaCheckbox implements ControlValueAccessor {
|
||||
@Input() disabled:boolean;
|
||||
@Input() label:string;
|
||||
@Input() value:string;
|
||||
@Input() name:string;
|
||||
@Input() baCheckboxClass:string;
|
||||
|
||||
public state: boolean;
|
||||
|
||||
onChange(value: any): void {}
|
||||
onTouch(value: any): void {}
|
||||
writeValue(value: any): void {
|
||||
this.state = value;
|
||||
}
|
||||
|
||||
registerOnChange(fn: any): void { this.onChange = fn; }
|
||||
registerOnTouched(fn: any): void { this.onTouch = fn; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue