简体   繁体   中英

Displaying 2D array with ngfor

I am pulling some message data from firebase database and trying to display them as a list on page using ngfor . The problem is this is structure of the data coming from db is 2 d array 在此处输入图片说明

code below explains the structure:

this.msg=messages[0][3]; //first users 3rd message content.(0 is key of messagecontent)
      this.msg=messages[0][3].message //first users 3rd message contents message.actual message i want to display.

msg is an observable.

so how do i write a proper ngfor for this data ?

thanks

Well, in the simplest way you can :)

<div *ngFor="let message of messages | async">
  <div *ngFor="let prop of message">
    <!-- You should have everything here -->
  </div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM