message.component.ts 592 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Component, OnInit } from '@angular/core';
import { MethodsService } from '../methods.service';

@Component({
  selector: 'app-message',
  templateUrl: './message.component.html',
  styleUrls: ['./message.component.css']
})
export class MessageComponent implements OnInit {

  message: string = ''

  constructor(private methodsService: MethodsService) { }

  ngOnInit() {
    this.message = this.methodsService.getMessage();
    // Service will tell when updated data is available!
    this.methodsService.newMessage.subscribe(signal => {
      this.message = signal;
    });
  }

}