Skip to content

Message Model

Thor Schueler edited this page Mar 10, 2017 · 2 revisions

The Message model implements the model for the NotificationBadge Component. An instance of the model is generated and delivered by the Notifications Service.

Properties

The Message model is a POCO with the following properties:

  • Title - Gets the message title
  • Body - Gets the message body (if any)
  • Date - Gets the message data
  • Image - Gets the url of an image (if any)
  • Detail - Gets the url for a more detailed representation of the message (if any)

Constructor

You can construct a new Message model instance using its constructor:

    constructor(
         title: string, 
         date: Date, 
         body?: string, 
         image?: string, 
         detail?: string)

Parameters:

  • title - String containing the message title
  • date - String containing the message date
  • body - Optional. String containing the message body
  • image - Optional. String containing a url to the message's picture
  • detail - Optional. String containing a url to a detailed representation of the message

Example

The following example implements a simple ng2 component using the Message model to display a message:

import { Component } from '@angular/core';
import { Message } from 'ng2-app-scaffold';
@Component({
    selector: 'message',
    template: `
       <div class="message"></div>
    `
})
export class User{
    message:Message;
    constructor(){
        this.message = new Message(
            'This is important',
            new Date());
    }
}  
Clone this wiki locally