import { Component , OnDestroy , OnInit } from '@angular/core' ; import { AlertService , Alert } from 'app/core/util/alert.service' ; @ Component ( { selector : 'jhi-alert' , templateUrl : './alert.component.html' , } ) export class AlertComponent implements OnInit , OnDestroy { alerts : Alert [ ] = [ ] ; constructor ( private alertService ) { } ngOnInit ( ) { this . alerts = this . alertService . get ( ) ; } setClasses ( alert ) { const classes = { 'jhi-toast' : Boolean ( alert . toast ) } ; if ( alert . position ) { return { ... classes , [ alert . position ] : true } ; } return classes ; } ngOnDestroy ( ) { this . alertService . clear ( ) ; } close ( alert ) { alert . close ?. ( this . alerts ) ; } }