diff src/app/mail.service.ts @ 1:44c99e3cb108

App skelton generated with angular-cli, as well as a few experiments (to be deleted).
author Lucas Thompson <dev@lucas.im>
date Tue, 25 Oct 2016 14:42:26 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/app/mail.service.ts	Tue Oct 25 14:42:26 2016 +0100
@@ -0,0 +1,22 @@
+import { Injectable } from '@angular/core';
+
+@Injectable()
+export class MailService {
+
+  messages = [
+    {id: 0, text: `You've got mail!`},
+    {id: 1, text: `No Mail!`},
+    {id: 2, text: `Spam!`}
+  ];
+
+  constructor() { }
+
+  update(id, text) {
+    this.messages = this.messages.map(message =>
+      message.id === id
+        ? {id, text}
+        : message
+    )
+  }
+
+}