aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/form-elements/checkbox/checkbox.component.ts
blob: ec05eac784d361884b7fb7e815d27ba81bdeb52b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
    @Output() checkedChange:EventEmitter<any> = new EventEmitter<any>();

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