File

src/app/providers/message.service.ts

Description

Provider for website action logs.

Index

Properties
Methods

Methods

add
add(message: string)

Adds a new message to the messages Array.

Parameters :
Name Type Optional Description
message string No

Messages data structure.

Example :
add("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
Returns : void
clear
clear()

Sets the messages Array to empty.

Returns : void

Properties

messages
messages: string[]
Type : string[]
Default value : []

Data structure due to store the different message logs generated by intertacting with website actions.

MessageService Documentation

Provider


Structure:

  • Provided in: Root

  • Type: String Array

      messages: string[] = [];
  • Methods:

    • add:
      Example:

        /** Location: service.ts */
        add(message: string){ ... }
      
        /** Location: component.ts */
        messageService.add("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
    • clear:
      Example:

        /** Location: service.ts */
        clear(){ ... }
      
        /** Location: component.ts */
        messageService.clear();

import { Injectable } from '@angular/core';

/**
 * Provider for website action logs.
 */
@Injectable({ providedIn: 'root' })
export class MessageService {

  /**
   * Data structure due to store the different message logs generated by
   * intertacting with website actions.
   */
  messages: string[] = [];

  /** 
   * Adds a new message to the messages [Array]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array}.
   * 
   * @description
   * Must be called passing the same message struture we are using
   * to show actions log in our HTML. You only need to call it with 1 value.
   * 
   * @example
   * add("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
   * 
   * @param {string[]} message Messages data structure.
   * 
   * */
  add(message: string) {
    this.messages.push(message);
  }

  /** 
   * Sets the messages Array to empty.
   * */
  clear() {
    this.messages = [];
  }
}

result-matching ""

    No results matching ""