F
F
furrya_black2017-08-27 03:26:18
Angular
furrya_black, 2017-08-27 03:26:18

Angular 2, how to know the state of a child ngIf without touching the child/component's code?

<roo-component>
    <div *ngIf="canOrNot">Oooops</div>
</root-component>

In the root component, I want to know the state of the ngIf directive, that is, ideally, in the root component, do something like:
@NgIfChildDirective() private ngIfD;
....
this.ngIfD.subscribe();

I want to track the state (show / hidden, that is, in the case of ngIf in the DOM or not the element)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
ozknemoy, 2017-08-27
@ozknemoy

if it is planned to use the subscriber, then it is enough to simply emit all changes to the canOrNot variable in the roo-component

F
furrya_black, 2017-08-27
@furrya_black

I am making an analogue from vue js, I went the way of my directives instead of ngIf. <transition></transition>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question