aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/form-elements/checkbox/checkbox.component.ts
blob: 2b50e6de3ff32c440918d0fdbea8494b5f8d64ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { Component, Input, Output, EventEmitter, ViewEncapsulation } from '@angular/core';
import { template } from "./checkbox.component.html";

@Component({
    selector: 'sdc-checkbox',
    template: template,
    encapsulation: ViewEncapsulation.None
})
export class CheckboxComponent {
    @Input() label:string;
    @Input() checked:boolean;
    @Input() disabled:boolean;
    @Input() testId: string;
    @Output() checkedChange:EventEmitter<any> = new EventEmitter<any>();

    public toggleState(newState:boolean) {
        if (!this.disabled) {
            this.checked = newState;
            this.checkedChange.emit(newState);
        }
    }
}