import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-alert', templateUrl: './alert.component.html', styleUrls: ['./alert.component.scss'] }) export class AlertComponent implements OnInit { alerts: Array = []; constructor() { this.alerts.push({ id: 1, type: 'success', message: 'This is an success alert', }, { id: 2, type: 'info', message: 'This is an info alert', }, { id: 3, type: 'warning', message: 'This is a warning alert', }, { id: 4, type: 'danger', message: 'This is a danger alert', }); } ngOnInit() { } public closeAlert(alert: any) { const index: number = this.alerts.indexOf(alert); this.alerts.splice(index, 1); } }