Skip to main content

*ngFor ntonot displaying data

Source Link

*ngFor nto displaying data

component.ts file

posts= [];
  constructor( private http:HttpClient) { 
    http.get('https://jsonplaceholder.typicode.com/posts')
    .subscribe(response=>{
      this.posts.push(response)
      console.log(this.posts)
    });
  }

in HTML file

<ul class="list-group">
  <li 
    *ngFor="let post of posts"
    class="list-group-item">{{post.title}}</li>
</ul>

I can see the data from array if I consoled but for some reason the *ngFor only displays one blank container.