AnswerBun.com

How to pass input variable in structure directive?

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>

Stack Overflow Asked by Alice Messis on January 27, 2021

1 Answers

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!

Related Questions

Bash: insert a line after each line

6  Asked on December 23, 2021 by mr-krisey

     

Recoding groups to create a summary accordingly

1  Asked on December 23, 2021 by rjunkie2

 

Is it a good idea to nest custom serializer classes in django?

1  Asked on December 23, 2021 by john-cymmer

 

create view by using two different array

3  Asked on December 23, 2021 by akshay-namdeo

         

Koltin: Pass Context from inner class

3  Asked on December 23, 2021 by sarah-smith

 

how to write mocha test that have timeout and async both

1  Asked on December 23, 2021 by jogiter

 

SQL CONCAT drops zeros from expression

2  Asked on December 23, 2021

   

Python – arguments to dictionary

0  Asked on December 23, 2021 by user13986859

   

Rundeck not able connect the domain servers

1  Asked on December 23, 2021 by jagadesh

 

Updating the index in an SQL database (python)

1  Asked on December 23, 2021 by luke-teo

     

Using mask to filter dataframe by multiple day of week

1  Asked on December 23, 2021 by meronpan

         

JQuery Menu Editor is not Compatible with AngularJS 1.5

1  Asked on December 23, 2021 by atique-ahmed

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved.