import { Directive , ChangeDetectorRef , AfterViewInit } from '@angular/core' ; import { NzFormLabelComponent } from 'ng-zorro-antd/form' ; import { NsFormItemDirective } from './ns-form-item.directive' ; @ Directive ( { selector : '[nsFormLabel]' , } ) export class NsFormLabelDirective implements AfterViewInit { constructor ( private label , private formItemDirective , private cd ) { formItemDirective . setLabel ( label ) ; } ngAfterViewInit ( ) { if ( this . formItemDirective . formControl . validateControl && this . formItemDirective . formControl . validateControl . errors && this . formItemDirective . formControl . validateControl . errors . required ) { if ( this . label . nzRequired === false ) { this . label . nzRequired = true ; this . cd . detectChanges ( ) ; } } } }