blob: 4281e1cf5e925af3ab7f209f99a971cb3d348c55 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import { Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { Guid } from 'guid-typescript';
import { CommentService } from 'src/app/services/comment.service';
@Component({
selector: 'app-comment-page',
templateUrl: './comment-page.component.html',
styleUrls: ['./comment-page.component.css']
})
export class CommentPageComponent implements OnInit {
private _title = 'Comment';
public dataArrived = false;
public postId: Guid;
public commentId: Guid;
constructor(private _titleService: Title, private _router: Router, private _commentService: CommentService) {
this._titleService.setTitle(this._title);
}
ngOnInit(): void {
this.commentId = Guid.parse(this._router.url.substring(9));
this.postId = Guid.createEmpty();
this._commentService.getCommentRequest(this.commentId).subscribe({
next: (result: object) => {
this.postId = Object.values(result)[1];
this.dataArrived = true;
},
error: () => {
this._router.navigate(['/not-found']);
}
});
}
goToPostPage(): void {
this._router.navigate(['/post/' + this.postId]);
}
}
|