Comment utiliser une fonction dans tous les composants
Bonjour, mon problème est simple : j'ai une fonction 'addChatWindow(id?: string, thread?: Thread)' instanciée dans mon composant 'ChatWindowsComponent'.
Je voudrais utilisé cette fonction dans une autre classe 'ChatThreadsComponent'.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
export class ChatWindowsComponent implements OnInit {
windows: Box[] = [new Box()];
constructor() {
this.windows = [
new Box()
];
}
ngOnInit(): void { }
addChatWindow(id?: string, thread?: Thread): void {
this.windows.push(new Box());
}
} |
Code:
1 2 3 4 5 6
|
export class ChatThreadsComponent implements OnInit {
onCreateChatWindow(id?: string): void {
addChatWindow(this.thread.id, this.thread); ?????????????
} |
Merci d'avance :)