I have an observable defined in my angular component like this.
profiles$!: Observable<Profile[] | undefined>;`
I try to check the length of this array in my template like this.
<div *ngIf="(profiles$ | async).length > 0"></div>
With this construct I get the error message Object is possibly 'null' or 'undefined'. from the typescript compiler which is totally fine. So add a null check to my if condition.
<div *ngIf="(profiles$ | async) && (profiles$ | async).length > 0"></div>
I'm still getting the same error that the object is possible null. I guess the compiler dose not recognise the null check. My question is how to do the null check to avoid the error from the typescript compiler.
(profiles$ | async)?.length > 0. I guess in the second example the compiler can't know that the value has to exist because of(profiles$ | async).