I am studying how to create a component dynamically in Angular. I can't understand the syntax:
(<AdComponent>componentRef.instance).data = adItem.data;
Can someone explain it?
I am studying how to create a component dynamically in Angular. I can't understand the syntax:
(<AdComponent>componentRef.instance).data = adItem.data;
Can someone explain it?
With this line (<AdComponent>componentRef.instance).data = adItem.data;
In fact you tell to TS the instance is type of AdComponent
it's only this.
So in your components who is loaded dynamically the @Input() data
is a AdComponent
like this
@Input() data:AdComponent