diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-28 15:00:19 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-03-28 15:00:19 +0300 |
| commit | 72a890d1b58fb27529d9dcd6ccd0951725fedebb (patch) | |
| tree | cbae174556e4dfcd01d896a68af09e44f165c158 /src/app/components/comment-page/comment-page.component.ts | |
| parent | 623f6dcc433149a41e93ce978ce5060ea46d7589 (diff) | |
| download | DevHive-Angular-72a890d1b58fb27529d9dcd6ccd0951725fedebb.tar DevHive-Angular-72a890d1b58fb27529d9dcd6ccd0951725fedebb.tar.gz DevHive-Angular-72a890d1b58fb27529d9dcd6ccd0951725fedebb.zip | |
Reimplemented comment page component
Diffstat (limited to 'src/app/components/comment-page/comment-page.component.ts')
| -rw-r--r-- | src/app/components/comment-page/comment-page.component.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/app/components/comment-page/comment-page.component.ts b/src/app/components/comment-page/comment-page.component.ts new file mode 100644 index 0000000..4281e1c --- /dev/null +++ b/src/app/components/comment-page/comment-page.component.ts @@ -0,0 +1,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]); + } +} |
