|
- import {Component, OnInit} from '@angular/core';
-
- import {User} from '@app/_models';
- import {AccountService} from '@app/_services';
- import {Subscription} from "rxjs";
- import {PostJsonld, PostService, UserJsonld, UserService} from "@app/core/api/v1";
-
- @Component({
- templateUrl: 'home.component.html',
- styleUrl: 'home.component.scss'
- })
- export class HomeComponent implements OnInit {
- protected user: User | null;
- protected postSub: Subscription;
- protected posts: Array<PostJsonld>;
-
- protected usersSub: Subscription;
- protected users: Array<UserJsonld>;
-
- constructor(
- private accountService: AccountService,
- private postService: PostService,
- private userService: UserService
- ) {
- this.user = this.accountService.userValue;
- // this.accountService.user.subscribe(x => this.user = x);
- this.postSub = new Subscription();
- this.posts = [];
-
- this.usersSub = new Subscription();
- this.users = [];
- }
-
- ngOnInit(): void {
- this.postSub = this.postService.postsGetCollection().subscribe(
- data => {
- this.posts = data["hydra:member"];
- }
- );
-
- this.usersSub = this.userService.usersGetCollection().subscribe(
- data => {
- this.users = data["hydra:member"];
- }
- );
- }
- }
|