3
votes

Ive looked at other anwsers to this question but havent found a solution

I'm getting the error in the title and while its not affecting the app i still would rather not have it.

<div *ngIf="currentUserData.healthCarePlans.length > 0">
    <p-carousel numVisible="3"
                [value]="currentUserData.healthCarePlans">
                    <ng-template let-insurance pTemplate="insurance">
                        <div>
                            <img class="company-header-avatar hc-img"
                                 [src]="insurance.imagePath">
                                      <div class="ui-g-12 hc-info">
                                          <div class="ui-g-6">

                          {{insurance.healthCareCompany.person.companyName}}
                                          </div>
                                          <div class="ui-g-6">
                                              {{insurance.code}}
                                          </div>
                                      </div>
                        </div>
                    </ng-template>
    </p-carousel>
</div>

I have tried the safe operator as usually that works but it doesnt seem to in this case

2
your ngIf is async. should probably be currentUserData?.healthCarePlans.lengthStavm
when you're using currentUserData.healthCarePlans.length something like this for async calls you to need to map it to model and so that currentUserData.healthCarePlans is assigned to empty arrayAbhishek Ekaanth
"I have tried the safe operator" <- please show it.Jeto
@AidanWard That's really weird that it didn't work.Jeto
I am curious to know what's the difference reallyStavm

2 Answers

1
votes

This could be because currentUserData is null , you can handle with

<div *ngIf="currentUserData && currentUserData.healthCarePlans.length > 0">
0
votes

Solved it with ngif ="currentuserdata" in a external div