import { Directive , ElementRef , Input , Renderer2 } from '@angular/core' ; import { BehaviorSubject } from 'rxjs' ; import { toBoolean } from '../../util/convert' ; import { uniqueId } from '../../util/util' ; @ Directive ( { selector : 'input[ngl][type=checkbox]' , } ) export class NglCheckboxInput { ɵRequiredSubject = new BehaviorSubject < boolean > ( false ) ; set describedBy ( value ) { this . renderer . setAttribute ( this . el . nativeElement , 'aria-describedby' , value ) ; } @ Input ( ) set required ( required ) { this . ɵRequiredSubject . next ( toBoolean ( required ) ) ; } constructor ( private el , private renderer ) { if ( ! this . el . nativeElement . id ) { this . renderer . setAttribute ( this . el . nativeElement , 'id' , uniqueId ( 'checkbox' ) ) ; } } get id ( ) { return this . el . nativeElement . id ; } addClass ( klass ) { this . renderer . addClass ( this . el . nativeElement , klass ) ; } }