S
S
sanex33392016-02-11 11:16:41
Angular
sanex3339, 2016-02-11 11:16:41

How to dynamically include a directive?

Essence: there is a ProgressBar directive.
At the moment, it is connected to the parent component immediately and takes up space on the screen.
I would like to make this directive loaded only when the 'change' event occurs in the parent component on the input with type="file", i.e. as soon as one or more files are selected for upload. It is at that moment that it makes sense to display this directive.
Is there any way to do this without creating a new visibility property on the parent component and passing its value as an attribute?

<progress-bar [visibility]="visibility" [progress]="uploadProgress"></progress-bar>

Or vice versa - the method indicated above is the most optimal?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Сергей Протько, 2016-02-11
@sanex3339

нет, компонент вернхенго уровня должен же как-то это контролировать. И да, называться свойство должно хотя бы "uploadInProgress", что бы было понятно из контекста что это такое.
p.s. тут лучше подходит ngIf

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question