Hey guys, let's say I have the following code in a structural directive.
const controlStatus$ = this.control.statusChanges.pipe(startWith(this.control.status)) const formSubmit$ = this.formSubmitService.getFormSubmitObservable(); this.element.nativeElement.style.display = 'none combineLatest([formSubmit$, controlStatus$]) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(([submit]) => { if (this.control.status === 'INVALID' && (submit || this.control.dirty || control.touched)) { this.element.nativeElement.style.display = 'block } else { this.element.nativeElement.style.display = 'none } });
Is it possible to get rid of the subscribe and takeUntilDestroyed here by using a declarative approach? In a component it would be easy to assign the observable stream to the async pipe.
But I cannot find a similar approach for directives. In fact, I wonder if there is anything similar?