0

I have a simple *ngFor loop and I cannot figure out why it's throwing an error

<ion-list>
  <ion-item *ngFor="let comment of [{'employee': 'jeremy lopez', 'desc': 'blah blah blah'}]">
    <ion-avatar item-left>
      <div class="initial-container">
        <div class="flex justify-content-center align-items-center">
          <div>{{ comment.employee }}</div>
        </div>
      </div>
    </ion-avatar>
    <p>{{ commment.desc }}</p>
  </ion-item>
</ion-list>

this throws an error TypeError: Cannot read property 'desc' of undefined even though it's clearly defined. When I move the {{ comment.desc }} up a couple lines in the DOM, it works:

<ion-item *ngFor="let comment of [{'employee': 'jeremy lopez', blah: 'blah blah blah'}]">
  <ion-avatar item-left>
    <div class="initial-container">
      <div class="flex justify-content-center align-items-center">
        <div>{{ comment.employee | initialFormat }}</div>
        <p>{{ commment.desc }}</p>
      </div>
    </div>
  </ion-avatar>
</ion-item>

which is great and all, but I need to be able to access comment.desc outside the <div class="initial-container"></div>.

Can someone explain what's happening?

1 Answer 1

4

commment is undefined, but comment is defined. You have a typo.

Sign up to request clarification or add additional context in comments.

1 Comment

-_- sheeeeeeshh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.