import { Component, Input } from '@angular/core'; import { ThreadsService } from '../services/threads.service'; import { Thread } from '../models/thread.model'; import { CommonModule } from '@angular/common'; @Component({ selector: 'app-chat-thread', imports: [CommonModule], templateUrl: './chat-thread.html', styleUrl: './chat-thread.css', }) export class ChatThread { // property selected = false; @Input() thread: Thread; // constructor constructor(public threadsService: ThreadsService) { } // constructor // methods // what to do when the user clicks on a row clicked(event: any): void { this.threadsService.setCurrentThread(this.thread); event.preventDefault(); // DOM refresh NOT POM refresh } // clicked ngOnInit(): void { this.threadsService.currentThread.subscribe( (currentThread: Thread) => { this.selected = currentThread && this.thread && (currentThread.id === this.thread.id); } ); // subscribe } // ngOnInit } // ChatThread