src/app/stores/error.store.ts
Properties |
Methods |
constructor(router: Router)
|
||||||
Defined in src/app/stores/error.store.ts:11
|
||||||
Parameters :
|
addError | ||||||
addError(title: , message: )
|
||||||
Defined in src/app/stores/error.store.ts:24
|
||||||
Parameters :
Returns :
void
|
displayErrors |
displayErrors()
|
Defined in src/app/stores/error.store.ts:35
|
Returns :
void
|
handle | ||||||
handle(error: IError)
|
||||||
Defined in src/app/stores/error.store.ts:15
|
||||||
Parameters :
Returns :
void
|
reset |
reset()
|
Defined in src/app/stores/error.store.ts:20
|
Returns :
void
|
showError | ||||||||||||
showError(title: string, message: string)
|
||||||||||||
Defined in src/app/stores/error.store.ts:29
|
||||||||||||
Parameters :
Returns :
void
|
errors |
errors:
|
Default value : new Array<AppError>()
|
Defined in src/app/stores/error.store.ts:11
|
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { AppError } from '../models';
interface IError {
title: string;
content: any;
}
@Injectable()
export class ErrorStore {
errors = new Array<AppError>();
constructor(private router: Router) {}
handle(error: IError) {
this.addError(error.title, error.content);
this.displayErrors();
}
reset() {
this.errors = new Array<AppError>();
}
addError(title, message) {
const error = new AppError(title, message);
this.errors.push(error);
}
showError(title = 'Error', message = 'An Error Has Occurred') {
const error = new AppError(title, message);
this.errors.push(error);
this.router.navigate(['/error']);
}
displayErrors() {
this.router.navigate(['/error']);
}
}