I am trying to pass two parameters to my directive as separate parameters. I manage to add the parameters as one parameter (*ovLoading="!isDataReceived;noBackground:true"), but I would like to have it as two separate parameters, is that somehow possible?:
My directive looks like this:
@Directive({
selector: `[ovLoading]`,
})
export class LoadingDirective implements OnChanges, OnInit {
@Input() public ovLoading: boolean;
@Input() public ovLoadingNoBackground = false;
private factory: ComponentFactory<LoaderComponent>;
private viewRef: EmbeddedViewRef<any>;
private loaderComponent: ComponentRef<LoaderComponent>;
constructor(
private templateRef: TemplateRef<any>,
private viewContainerRef: ViewContainerRef,
private componentFactoryResolver: ComponentFactoryResolver,
) {
this.factory = this.componentFactoryResolver.resolveComponentFactory(LoaderComponent);
}
public ngOnInit() {
}
public ngOnChanges() {
if (this.viewRef == null) {
this.viewRef = this.viewContainerRef.createEmbeddedView(this.templateRef);
}
if (this.ovLoading) {
this.loaderComponent = this.viewContainerRef.createComponent(this.factory);
this.loaderComponent.instance.noBackground = this.ovLoadingNoBackground;
} else if (this.loaderComponent != null) {
this.viewContainerRef.remove(this.viewContainerRef.indexOf(this.loaderComponent.hostView));
this.loaderComponent = null;
}
}
}
Her is how I use it (This is working):
<div class="header" *ovLoading="!isDataReceived;noBackground:true"></div>
And I would like to have it something like this (this is not working):
<div class="grid-view-header" *ovLoading="!isDataReceived" noBackground="true">