-
Notifications
You must be signed in to change notification settings - Fork 362
/
bootstrap.toast.ts
52 lines (48 loc) 路 1.45 KB
/
bootstrap.toast.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Component } from '@angular/core';
import { Toast, ToastrService, ToastPackage } from '../lib/public_api';
@Component({
selector: '[bootstrap-toast-component]',
template: `
<div class="toast" role="alert" [style.display]="state.value === 'inactive' ? 'none' : ''">
<div class="toast-header">
<strong class="me-auto">{{ title || 'default header' }}</strong>
<button
type="button"
class="btn-close"
aria-label="Close"
*ngIf="options.closeButton"
(click)="remove()"
></button>
</div>
<div class="toast-body">
<div
role="alert"
[attr.aria-label]="message"
>
{{ message || 'default message' }}
</div>
<div class="mt-2 pt-2 border-top">
<button type="button" class="btn btn-secondary btn-sm" (click)="handleClick($event)">
{{ undoString }}
</button>
</div>
</div>
</div>
`,
preserveWhitespaces: false,
})
export class BootstrapToast extends Toast {
// used for demo purposes
undoString = 'undo';
// constructor is only necessary when not using AoT
constructor(protected toastrService: ToastrService, public toastPackage: ToastPackage) {
super(toastrService, toastPackage);
}
// Demo click handler
handleClick(event: Event) {
event.stopPropagation();
this.undoString = 'undid';
this.toastPackage.triggerAction();
return false;
}
}