feat: The available chatrooms are fetched and displayed in a component
[demos/kafka/chat] / src / app / chatrooms / chatrooms.component.ts
1 import { Component, OnInit } from '@angular/core';
2 import { FormsModule } from '@angular/forms';
3 import { Chatroom } from '../chatroom';
4 import { ChatroomService } from "../chatroom.service";
5
6 @Component({
7   selector: 'app-chatrooms',
8   templateUrl: './chatrooms.component.html',
9   styleUrls: ['./chatrooms.component.less']
10 })
11 export class ChatroomsComponent  implements OnInit
12 {
13   chatrooms: Chatroom[] = [];
14
15   constructor(private chatroomsService: ChatroomService) { }
16
17   ngOnInit(): void
18   {
19     this.getChatrooms();
20   }
21
22   getChatrooms(): void {
23     this.chatroomsService
24       .getChatrooms()
25       .subscribe(chatrooms => this.chatrooms = chatrooms);
26   }
27 }