d) Show messages - Create the MessageService
--- /dev/null
+import { TestBed } from '@angular/core/testing';
+
+import { MessageService } from './message.service';
+
+describe('MessageService', () => {
+ beforeEach(() => TestBed.configureTestingModule({}));
+
+ it('should be created', () => {
+ const service: MessageService = TestBed.get(MessageService);
+ expect(service).toBeTruthy();
+ });
+});
--- /dev/null
+import { Injectable } from '@angular/core';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class MessageService {
+
+ messages : string[] = [];
+
+ add(message : string): void {
+ this.messages.push(message);
+ }
+
+ clear(): void {
+ this.messages = [];
+ }
+}