import { Component , OnInit , Input } from '@angular/core' ; import { MessagesService } from '../../services/messages.service' ; import { LoggerService } from '../../services/logger.service' ; import { Message } from '../../models/message' ; @ Component ( { selector : '.messagesBox' , styleUrls : [ './messages-box.component.css' ] , templateUrl : './messages-box.component.html' } ) export class MessagesBoxComponent implements OnInit { public messages : Message [ ] ; msgLength = { 0 : 0 } ; constructor ( private msgServ , private logger ) { this . messages = [ ] ; } public ngOnInit ( ) { this . msgServ . messages . subscribe ( ( msg ) => { this . logger . log ( 'MsgBox' , null , 'RECEIVED.MESSAGE' , null ) ; this . messages = msg ; this . msgLength = { 0 : this . messages . length } ; } ) ; } }