23 lines
567 B
TypeScript
23 lines
567 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { DataloaderService } from 'app/services/dataloader.service';
|
|
import { Post } from '../../model/post';
|
|
import { Observable } from 'rxjs/Observable';
|
|
|
|
@Component({
|
|
selector: 'app-posts',
|
|
templateUrl: './posts.component.html',
|
|
styleUrls: ['./posts.component.css']
|
|
})
|
|
export class PostsComponent implements OnInit {
|
|
|
|
posts:Observable<Post[]>;
|
|
|
|
constructor(private dataloaderService:DataloaderService) { }
|
|
|
|
ngOnInit() {
|
|
//fetch the posts
|
|
this.posts = this.dataloaderService.getPosts();
|
|
}
|
|
|
|
}
|