Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

48 řádky
1.3 KiB

  1. import {Component, OnInit} from '@angular/core';
  2. import {User} from '@app/_models';
  3. import {AccountService} from '@app/_services';
  4. import {Subscription} from "rxjs";
  5. import {PostJsonld, PostService, UserJsonld, UserService} from "@app/core/api/v1";
  6. @Component({
  7. templateUrl: 'home.component.html',
  8. styleUrl: 'home.component.scss'
  9. })
  10. export class HomeComponent implements OnInit {
  11. protected user: User | null;
  12. protected postSub: Subscription;
  13. protected posts: Array<PostJsonld>;
  14. protected usersSub: Subscription;
  15. protected users: Array<UserJsonld>;
  16. constructor(
  17. private accountService: AccountService,
  18. private postService: PostService,
  19. private userService: UserService
  20. ) {
  21. this.user = this.accountService.userValue;
  22. // this.accountService.user.subscribe(x => this.user = x);
  23. this.postSub = new Subscription();
  24. this.posts = [];
  25. this.usersSub = new Subscription();
  26. this.users = [];
  27. }
  28. ngOnInit(): void {
  29. this.postSub = this.postService.postsGetCollection().subscribe(
  30. data => {
  31. this.posts = data["hydra:member"];
  32. }
  33. );
  34. this.usersSub = this.userService.usersGetCollection().subscribe(
  35. data => {
  36. this.users = data["hydra:member"];
  37. }
  38. );
  39. }
  40. }