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

Add notification and dialog to component create-comment

parent 5ba649b1
Branches
Tags
No related merge requests found
import { Component, OnInit, Input } from '@angular/core';
import {Component, OnInit, Input, Inject} from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { Room } from '../room';
import { Comment } from '../comment';
import { RoomService } from '../room.service';
import { CommentService} from '../comment.service';
import { NotificationService } from '../notification.service';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
@Component({
selector: 'app-create-comment',
......@@ -19,7 +21,9 @@ export class CreateCommentComponent implements OnInit {
private roomService: RoomService,
private commentService: CommentService,
private location: Location,
) { }
private notification: NotificationService,
public dialogRef: MatDialogRef<CreateCommentComponent>,
@Inject(MAT_DIALOG_DATA) public data: any) { }
ngOnInit(): void {
this.route.params.subscribe(params => {
......@@ -42,7 +46,10 @@ export class CreateCommentComponent implements OnInit {
subject: subject,
body: body,
creationTimestamp: new Date(Date.now())
} as Comment).subscribe();
} as Comment).subscribe(room => {
this.notification.show(`Comment '${subject}' successfully created.`);
this.dialogRef.close();
});
}
goBack(): void {
......
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