comparison 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
comparison
equal deleted inserted replaced
0:340ce94899fd 1:44c99e3cb108
1 import { Injectable } from '@angular/core';
2
3 @Injectable()
4 export class MailService {
5
6 messages = [
7 {id: 0, text: `You've got mail!`},
8 {id: 1, text: `No Mail!`},
9 {id: 2, text: `Spam!`}
10 ];
11
12 constructor() { }
13
14 update(id, text) {
15 this.messages = this.messages.map(message =>
16 message.id === id
17 ? {id, text}
18 : message
19 )
20 }
21
22 }