Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { Component, OnInit } from '@angular/core';
import { PostService } from 'src/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 => {
this.posts = res;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment