2017-06-02 26 views
0

は、私はシンプルな*ngForループを持っており、それは誤り角度2:ngForループ未定義値

<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> 

これは、それが明確に定義されていていてもエラーTypeError: Cannot read property 'desc' of undefinedをスローを投げ、なぜ私が理解することはできません。素晴らしいとすべてです

<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> 

を、私は<div class="initial-container"></div>comment.descにアクセスできるようにする必要があります:私はDOMに{{ comment.desc }}アップカップルのラインを移動すると、それが動作します。

誰かが何が起こっているのか説明できますか?

答えて

4

commmentundefinedであるが、commentが定義されている。あなたはタイプミスがあります。

+0

-_- sheeeeeeshh –