1

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 enter image description here

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

1

1 Answer 1

3

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>
Sign up to request clarification or add additional context in comments.

7 Comments

0th member of message content is key
Sorry, what ? You asked for a way to double loop on it. Could you state your current need instead ?
No, the async pipe causes an error. You told me messages was an Observable, but it seems it isn't. Delete the second | async, if it still doesn't work, delete the first too.
You don't need | async at all since messages isn't an Observable, this.msg is (according to OP). Make sure you put some html inside so you actually see something on the screen.
|

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.