Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { PostService } from '../../services/post.service';
  3. import { AuthService } from '../../services/auth.service';
  4. import { Router } from '@angular/router';
  5.  
  6. @Component({
  7. selector: 'app-dashboard',
  8. templateUrl: './dashboard.component.html',
  9. styleUrls: ['./dashboard.component.css']
  10. })
  11. export class DashboardComponent implements OnInit {
  12. posts: any[];
  13.  
  14. constructor( private postService: PostService, private auth: AuthService, private router: Router ) { }
  15.  
  16. ngOnInit() {
  17. this.getPosts();
  18. }
  19.  
  20. getPosts() {
  21. this.postService.getPostsByAuthor().subscribe((result) => {
  22. this.posts = result['data'];
  23. console.log( this.posts );
  24. });
  25. }
  26.  
  27. logout() {
  28. this.auth.logout();
  29. this.router.navigate(['']);
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement