From 4a0424ef3419ae8311f8dfa8b427feb6e43b6aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 16 Feb 2018 17:49:57 +0100 Subject: [PATCH] Fix messages not showing (detectChanges()) --- src/app/messages/messages.component.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/messages/messages.component.ts b/src/app/messages/messages.component.ts index 4619921..6b4c30c 100644 --- a/src/app/messages/messages.component.ts +++ b/src/app/messages/messages.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { ChangeDetectorRef, Component, OnInit } from '@angular/core'; import { MarkdownService } from '../markdown.service'; import { WebSocketService } from '../websocket.service'; @@ -13,7 +13,8 @@ export class MessagesComponent implements OnInit { messages: Message[] = []; constructor( private markdownService: MarkdownService, - private websocketService: WebSocketService + private websocketService: WebSocketService, + private changeDetectorRef: ChangeDetectorRef ) {} convert(text: string) { @@ -24,11 +25,10 @@ export class MessagesComponent implements OnInit { this.websocketService.connect(); this.websocketService.observeAnchor('message').subscribe( (event) => { - console.log(event.data); this.messages.push(event.data); event.data.message = this.convert(event.data.message); + this.changeDetectorRef.detectChanges(); } ); } - }