Skip to content

Instantly share code, notes, and snippets.

@mkubdev
Created October 21, 2020 09:40
Show Gist options
  • Select an option

  • Save mkubdev/94c46a46524f59a5e6af6352b91ac1cb to your computer and use it in GitHub Desktop.

Select an option

Save mkubdev/94c46a46524f59a5e6af6352b91ac1cb to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { PostService } from 'services/post.service';
@Component({
selector: 'app-post',
templateUrl: './post.component.html',
styleUrls: ['./post.component.scss']
})
export class PostComponent implements OnInit {
posts: any = [];
constructor(private postSvc: PostService) { }
ngOnInit() {
this.postSvc.getAllPosts().subscribe(res => {
console.log("posts", res);
this.posts = res;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment