-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathtoast-overview-example.ts
More file actions
61 lines (52 loc) · 1.9 KB
/
Copy pathtoast-overview-example.ts
File metadata and controls
61 lines (52 loc) · 1.9 KB
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
53
54
55
56
57
58
59
60
61
/* tslint:disable:no-console */
import { ChangeDetectionStrategy, Component, TemplateRef, ViewEncapsulation } from '@angular/core';
import { ThemePalette } from '@ptsecurity/mosaic/core';
import { McToastData, McToastStyle, McToastService, McToastComponent } from '@ptsecurity/mosaic/toast';
@Component({
selector: 'mc-new-toast',
template: '<div>MyToastComponent</div>',
host: {
class: 'my-toast'
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None
})
export class MyToastComponent extends McToastComponent {
constructor(
readonly data: McToastData,
readonly service: McToastService
) {
super(data, service);
console.log('MyToastComponent: ');
}
}
/**
* @title Basic Toast
*/
@Component({
selector: 'toast-overview-example',
templateUrl: 'toast-overview-example.html',
styleUrls: ['toast-overview-example.css']
})
export class ToastOverviewExample {
themePalette = ThemePalette;
constructor(
private toastService: McToastService,
private newToastService: McToastService<MyToastComponent>
) {}
showToast(style: McToastStyle) {
this.toastService.show({ style, title: 'Success', content: 'Message Content' });
}
showToastTitleTemplate(style: McToastStyle, template: TemplateRef<any>) {
this.toastService.show({ style, title: template, content: 'Message Content' });
}
showToastContentTemplate(style: McToastStyle, template: TemplateRef<any>) {
this.toastService.show({ style, title: 'Success', content: template });
}
showNewToast(style: McToastStyle) {
this.newToastService.show({ style, title: 'Success', content: 'Message Content' });
}
showTemplate(style: McToastStyle, template: TemplateRef<any>) {
this.toastService.showTemplate({ style, title: 'Success', content: 'Message Content' }, template);
}
}