import { ElementRef , Directive , AfterViewInit , Input , OnDestroy } from "@angular/core" ; import { instanceResolver , SpinnerDirective } from "@rxweb/framework" ; import { NgModule } from "@angular/core" ; import { CommonModule } from "@angular/common" ; @ Directive ( { selector : '[rxSpinner]' , } ) export class RxSpinnerDirective implements AfterViewInit , OnDestroy { private _spinner : boolean ; private element : any ; @ Input ( ) componentId : string ; @ Input ( 'rxSpinner' ) set spinner ( value ) { this . _spinner = value ; if ( this . spinnerDirective ) this . bind ( ) ; } constructor ( private elementRef ) { this . element = this . elementRef . nativeElement as Node ; } get spinner ( ) { return this . _spinner ; } private spinnerDirective : SpinnerDirective ; ngAfterViewInit ( ) { this . spinnerDirective = < SpinnerDirective > instanceResolver ( "rxSpinner" , this . element ) ; this . bind ( ) ; } bind ( ) { this . spinnerDirective . valueChange ( this . _spinner ) ; } ngOnDestroy ( ) { this . spinnerDirective . destroy ( ) ; } } @ NgModule ( { imports : [ CommonModule ] , exports : [ RxSpinnerDirective ] , declarations : [ RxSpinnerDirective ] } ) export class RxSpinnerModule { }