Basically I have a data that sometimes the value is null and sometimes the value is an empty array , it should still render the template if leaseApDto is not null or leaseApDto.length not equal to 0.
I tried to use the condition model.leaseApDto !== null || model.leaseApDto.length !=== 0 but they dont seem to work together even if its an OR condition.
Any idea ? would really appreciate it. Thanks.
leaseApDto with a null value
leaseApDto with an empty value but is an array
#code
<div *ngIf="model.leaseApDto !== null || model.leaseApDto.length !=== 0" class="transaction-lease-details-list">
<div class="description-header">
</div>
<div>
<div class="transaction-lease-details-content list-row-divider">
<div class="transaction-lease-details-left-label">
Current Base Rent (Annual)
</div>
>Solution :
For your case, wouldn’t replacing || with && resolve your issue?
Or you can simply use
*ngIf="model.leaseApDto?.length"
? is the safe navigation operator and helps to decrease a lot of code, and also helpful in such cases.
I would personally add the check to model too, like *ngIf="model?.leaseApDto?.length"

