diff --git a/src/app/create-comment/create-comment.component.ts b/src/app/create-comment/create-comment.component.ts index 59e8b2d932969ab733aebffea34ceece1b208287..f53b5eb806c4cd0b8d6ca14c95c2a5a0208bade5 100644 --- a/src/app/create-comment/create-comment.component.ts +++ b/src/app/create-comment/create-comment.component.ts @@ -22,20 +22,20 @@ export class CreateCommentComponent implements OnInit { ) { } ngOnInit(): void { - // this.getRoom(); + this.route.params.subscribe(params => { + this.getRoom(params['roomId']); + }); } - getRoom(): void { - const id = this.route.snapshot.paramMap.get('id'); - this.roomService.getRoom(id) - .subscribe(room => this.room = room); + getRoom(id: string): void { + this.roomService.getRoom(id).subscribe(room => this.room = room); } send(subject: string, text: string): void { subject = subject.trim(); text = text.trim(); if (!subject || !text) { return; } - this.commentService.addComment( { subject } as Comment ) + this.commentService.addComment( { subject: subject, body: text } as Comment ) .subscribe(); }