import { Component, Input, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-notification',
standalone: true,
imports: [CommonModule],
template: `
@if (visible) {
@if (type === 'success') {
}
@if (type === 'error') {
}
{{ title }}
{{ message }}
}
`
})
export class NotificationComponent implements OnInit {
@Input() title = '';
@Input() message = '';
@Input() type: 'success' | 'error' = 'success';
@Input() duration = 5000;
visible = true;
ngOnInit() {
if (this.duration > 0) {
setTimeout(() => this.close(), this.duration);
}
}
close() {
this.visible = false;
}
}