If I have the following:
{{user.name}}&l
The *ngIf
will remove that DOM element and all attached components/directives. So you can just write a simple directive that executes an event when it's first created. When the *ngIf
transitions from false to true the directive will be created (again, and again, etc...)
@Directive({selector: '[after-if]'})
export class AfterIfDirective implements AfterContentInit {
@Output('after-if')
public after: EventEmitter = new EventEmitter();
public ngAfterContentInit(): void {
// timeout helps prevent unexpected change errors
setTimeout(()=> this.after.next());
}
}
Sample HTML:
{{user.name}}