1234567891011121314151617181920212223242526272829303132333435 |
- import { Component, OnDestroy, OnInit } from '@angular/core';
- import { JhiAlertService } from 'ng-jhipster';
-
- @Component({
- selector: 'jhi-alert',
- template: `
- <div class="alerts" role="alert">
- <div *ngFor="let alert of alerts" [ngClass]="setClasses(alert)">
- <ngb-alert *ngIf="alert && alert.type && alert.msg" [type]="alert.type" (close)="alert.close(alerts)">
- <pre [innerHTML]="alert.msg"></pre>
- </ngb-alert>
- </div>
- </div>`
- })
- export class JhiAlertComponent implements OnInit, OnDestroy {
- alerts: any[];
-
- constructor(private alertService: JhiAlertService) {}
-
- ngOnInit() {
- this.alerts = this.alertService.get();
- }
-
- setClasses(alert) {
- return {
- toast: !!alert.toast,
- [alert.position]: true
- };
- }
-
- ngOnDestroy() {
- this.alerts = [];
- }
- }
|