Guest User

Untitled

a guest
Jun 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import { MessageService } from './message.service';
  2. import { Component, OnInit } from '@angular/core';
  3.  
  4. @Component({
  5. selector: 'app-root',
  6. templateUrl: './app.component.html',
  7. styleUrls: ['./app.component.css']
  8. })
  9. export class AppComponent implements OnInit {
  10.  
  11. title = 'app';
  12. message = '';
  13.  
  14. ngOnInit(): void {
  15. this.printMessage();
  16. }
  17.  
  18. constructor(private messageService: MessageService) {
  19. }
  20.  
  21. printMessage(): void {
  22. this.messageService.printMessage()
  23. .subscribe(message => this.message = message);
  24. }
  25.  
  26. }
Add Comment
Please, Sign In to add comment