Skip to content
Snippets Groups Projects
comment-list.component.ts 1.14 KiB
Newer Older
import { Component, OnInit } from '@angular/core';
import { Comment } from '../../../models/comment';
import { CommentService } from '../../../services/http/comment.service';
import { TranslateService } from '@ngx-translate/core';
import { LanguageService } from '../../../services/util/language.service';
  selector: 'app-comment-list',
  templateUrl: './comment-list.component.html',
  styleUrls: ['./comment-list.component.scss']
export class CommentListComponent implements OnInit {
  comments: Comment[];
  isLoading = true;
Lukas Mauß's avatar
Lukas Mauß committed
  roomId: string;
  constructor(private commentService: CommentService,
              private translateService: TranslateService,
              protected langService: LanguageService) {
    langService.langEmitter.subscribe(lang => translateService.use(lang));
    this.roomId = localStorage.getItem(`roomId`);
Lukas Mauß's avatar
Lukas Mauß committed
    this.getComments();
    this.translateService.use(localStorage.getItem('currentLang'));
Lukas Mauß's avatar
Lukas Mauß committed
  getComments(): void {
      this.commentService.getComments(this.roomId)
        .subscribe(comments => {
          this.comments = comments;
          this.isLoading = false;
        });