import { Directive , DoCheck , Inject , Input , OnChanges , Optional , SimpleChanges , } from '@angular/core' ; import { DynamicComponentInjector , DynamicComponentInjectorToken , } from '../component-injector' ; import { InputsType , IoService , OutputsType } from '../io' ; @ Directive ( { selector : '[ndcDynamicInputs],[ndcDynamicOutputs],[ngComponentOutletNdcDynamicInputs],[ngComponentOutletNdcDynamicOutputs]' , providers : [ IoService ] , } ) export class DynamicIoDirective implements OnChanges , DoCheck { @ Input ( ) ndcDynamicInputs : InputsType ; @ Input ( ) ngComponentOutletNdcDynamicInputs : InputsType ; @ Input ( ) ndcDynamicOutputs : OutputsType ; @ Input ( ) ngComponentOutletNdcDynamicOutputs : OutputsType ; private get inputs ( ) { return this . ndcDynamicInputs || this . ngComponentOutletNdcDynamicInputs ; } private get outputs ( ) { return this . ndcDynamicOutputs || this . ngComponentOutletNdcDynamicOutputs ; } constructor ( private ioService , @ Inject ( DynamicComponentInjectorToken ) @ Optional ( ) private componentInjector ? ) { this . ioService . init ( this . componentInjector ) ; } ngOnChanges ( changes ) { this . ioService . update ( this . inputs , this . outputs , this . inputsChanged ( changes ) , this . outputsChanged ( changes ) ) ; } ngDoCheck ( ) { this . ioService . maybeUpdate ( ) ; } private inputsChanged ( changes ) { return ( 'ngComponentOutletNdcDynamicInputs' in changes || 'ndcDynamicInputs' in changes ) ; } private outputsChanged ( changes ) { return ( 'ngComponentOutletNdcDynamicOutputs' in changes || 'ndcDynamicOutputs' in changes ) ; } }