Skip to content
Snippets Groups Projects
Commit 777a7eda authored by Hagen Dreßler's avatar Hagen Dreßler
Browse files

Add logic functions to component create-comment

parent 1f321334
No related merge requests found
......@@ -3,6 +3,8 @@ import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { Room } from '../room';
import { RoomService } from '../room.service';
import { CommentService} from '../comment.service';
@Component({
selector: 'app-create-comment',
......@@ -14,18 +16,28 @@ export class CreateCommentComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private roomService: RoomService,
private commentService: CommentService,
private location: Location,
) { }
ngOnInit(): void {
this.getRoom();
// this.getRoom();
}
getRoom(): void {
const id = +this.route.snapshot.paramMap.get('id');
const id = this.route.snapshot.paramMap.get('id');
this.roomService.getRoom(id)
.subscribe(room => this.room = room);
}
send(subject: string, text: string): void {}
send(subject: string, text: string): void {
subject = subject.trim();
text = text.trim();
if (!subject || !text) { return; }
this.commentService.addComment( { subject } as Comment )
.subscribe();
}
goBack(): void {
this.location.back();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment