TransWikia.com

How to pass input variable in structure directive?

Stack Overflow Asked by Alice Messis on January 27, 2021

There is a structure directive:

 @Directive({
        selector: '[loading]',
    })
    export class LoadingDirective {
        loadingFactory: ComponentFactory<LoadingComponent>;
        loadingComponent: ComponentRef<LoadingComponent>;

        @Input()
        set loading(loading: boolean) {}
        @Input('loadingSize') size: number;
    
    }

I have tried to pass size:

<span *loading="true size=20"></span>

One Answer

<span [loading]="true" [loadingSize]="20"></span>

Each input property stands on its own, and the * is not necessary

EDIT

change

        @Input()
        set loading(loading: boolean) {}

to

@Input() loading: boolean;

otherwise you are not doing anything with the value, since your setter function is empty

Correct answer by PMO1948 on January 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP