How can I display object data

I pass id via url in my angularfire2 application and collect it in the onInit method

  ngOnInit() {
    // subscribe to router event
    this.activatedRoute.params.subscribe((params: Params) => {
      this.groupId = params['groupId'];
      // grab specific group
      this.group = this.af.database.object('/groups/'+this.groupId);
      this.group.subscribe(console.log);
    });
  }

console.log perfectly shows the object that I want, but I can’t display it using HTML c {{group.data}}, instead I get a string [object Object].

I get the same result using also an observable list, but in the console log I get a bunch of data arrays that I want instead of 1 object to make the object preferable if possible.

What do I need to do to display the data?

+4
source share
2 answers

, , group Observable, async :

<div>
   {{group | async}}
</div>
+2
console.log(JSON.stringify(yourObject));

, RXJS.

this.activatedRoute.params.do(x => console.log(x)).subscribe 

HTML , JSON-.

..

{{ yourObject }}

.

{{ yourObject | json }}

.

<ul>
    <li *ngFor="let item in list">
        {{ item | json }}
    </li>
</ul>
0

Source: https://habr.com/ru/post/1671423/


All Articles