Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import { Component, OnInit, OnDestroy } from '@angular/core';
import { ToastData } from './toast-config';
import { ToastRef } from './toast-ref';
@Component({
selector: 'app-toast',
templateUrl: './toast.component.html',
})
export class ToastComponent implements OnInit, OnDestroy {
iconType: string;
private intervalId: number;
constructor(readonly data: ToastData, readonly ref: ToastRef) {
this.iconType = data.type === 'success' ? 'done' : data.type;
}
ngOnInit() {
this.intervalId = setTimeout(() => this.close(), 5000);
}
ngOnDestroy() {
clearTimeout(this.intervalId);
}
close() {
this.ref.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.