view 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 source
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
    )
  }

}