src/app/providers/message.service.ts
Provider for website action logs.
Properties |
Methods |
| add | ||||||||
add(message: string)
|
||||||||
|
Defined in src/app/providers/message.service.ts:28
|
||||||||
|
Adds a new message to the messages Array.
Parameters :
Example :
Returns :
void
|
| clear |
clear()
|
|
Defined in src/app/providers/message.service.ts:35
|
|
Sets the messages Array to empty.
Returns :
void
|
| messages |
messages:
|
Type : string[]
|
Default value : []
|
|
Defined in src/app/providers/message.service.ts:13
|
|
Data structure due to store the different message logs generated by intertacting with website actions. |
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 = [];
}
}