blob: 4fd024e2cb15fd9b7494617e4f2e27143960f88f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import {Injectable, ViewContainerRef} from '@angular/core';
import {ToastComponent} from '../components/toast/toast.component';
export enum ToastType {
INFO,
WARNING,
ERROR
}
@Injectable({
providedIn: 'root'
})
export class ToastsService {
private vcr?: ViewContainerRef
sendToast(type: ToastType, message: string, action?: {label: string, onAction: () => void}) {
let compRef = this.vcr?.createComponent(ToastComponent)!
compRef.setInput("message", message)
compRef.setInput("type", type)
compRef.setInput("action", action)
}
setRootViewContainerRef(vcr: ViewContainerRef) {
this.vcr = vcr
}
}
|