import { ChangeDetectionStrategy, Component, Input, OnInit, } from '@angular/core'; import { FormControlState, } from 'ngrx-forms'; import { UUID } from 'angular2-uuid'; @Component({ changeDetection: ChangeDetectionStrategy.OnPush, selector: 'ngrx-form-checkbox-component', styleUrls: [ './ngrx-form-checkbox.component.scss', ], templateUrl: './ngrx-form-checkbox.component.template.pug', }) export class NgrxFormCheckboxComponent implements OnInit { @Input() public label: string; @Input() public formControl: FormControlState; @Input() public showInvalidMessages: boolean; @Input() public additionalInputClasses: string[]; public inputId: string; public ngOnInit() { this.inputId = `ngrx-form-checkbox-${UUID.UUID()}`; } public get hasValue() { return this.formControl.value; } public get showInvalid() { return this.showInvalidMessages && this.formControl.isInvalid; } }