24 lines
867 B
TypeScript
24 lines
867 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { Post } from '../../model/Post';
|
|
import { User } from '../../model/User';
|
|
import { PostService } from '../services/data/post.service';
|
|
import { ActivatedRoute } from '@angular/router';
|
|
import { UserService } from '../services/data/user.service';
|
|
|
|
@Component({
|
|
selector: 'app-user',
|
|
templateUrl: './user.component.html',
|
|
styleUrl: './user.component.scss'
|
|
})
|
|
export class UserComponent implements OnInit{
|
|
user: User | undefined;
|
|
posts: Array<Post> | undefined;
|
|
|
|
constructor(private postService: PostService, private userService: UserService, private route: ActivatedRoute) { }
|
|
|
|
async ngOnInit(): Promise<void> {
|
|
this.user = await this.userService.getUser(this.route.snapshot.params['username']);
|
|
this.posts = await this.postService.getPosts(this.route.snapshot.params['username']);
|
|
}
|
|
}
|