|
1 | | -import { AfterViewInit, Component, inject } from "@angular/core"; |
| 1 | +import { Component } from "@angular/core"; |
2 | 2 | import { RouterOutlet } from "@angular/router"; |
3 | | -import { |
4 | | - DefaultTypeClasses, |
5 | | - DefaultIconClasses, |
6 | | - IToasterConfig, |
7 | | - ToasterConfig, |
8 | | - Toast, |
9 | | - ToastType, |
10 | | - ToasterService, |
11 | | - ToasterContainerComponent, |
12 | | -} from "angular-toaster"; |
13 | | - |
14 | | -type ExtendedToastType = ("customtype" | "bad value") & ToastType; |
| 3 | +import { NavbarComponent } from "./components/navbar/navbar.component"; |
15 | 4 |
|
16 | 5 | @Component({ |
17 | 6 | selector: "app-root", |
18 | | - imports: [RouterOutlet, ToasterContainerComponent], |
| 7 | + imports: [RouterOutlet, NavbarComponent], |
19 | 8 | templateUrl: "./app.component.html", |
20 | 9 | styleUrl: "./app.component.scss", |
21 | 10 | }) |
22 | | -export class AppComponent implements AfterViewInit { |
23 | | - title = "dev-app"; |
24 | | - |
25 | | - extendedTypeClasses = { |
26 | | - ...DefaultTypeClasses, |
27 | | - ...{ customtype: "angular-toast-success" }, |
28 | | - }; |
29 | | - extendedIconClasses = { |
30 | | - ...DefaultIconClasses, |
31 | | - ...{ customtype: "icon-error" }, |
32 | | - }; |
33 | | - |
34 | | - config: IToasterConfig = new ToasterConfig({ |
35 | | - animation: "fade", |
36 | | - newestOnTop: true, |
37 | | - positionClass: "angular-toast-bottom-right", |
38 | | - toastContainerId: 1, |
39 | | - timeout: 0, |
40 | | - showCloseButton: true, // mouseoverTimerStop: true |
41 | | - typeClasses: this.extendedTypeClasses as ExtendedToastType, |
42 | | - iconClasses: this.extendedIconClasses as ExtendedToastType, |
43 | | - }); |
44 | | - |
45 | | - public toasterService: ToasterService = inject(ToasterService); |
46 | | - |
47 | | - show(type: ToastType) { |
48 | | - this.toasterService.pop({ |
49 | | - type, |
50 | | - title: "Hello world!", |
51 | | - body: "Toastr fun!", |
52 | | - timeout: 10000, |
53 | | - }); |
54 | | - } |
55 | | - |
56 | | - popToast() { |
57 | | - const toast = this.toasterService.pop({ |
58 | | - type: "success", |
59 | | - title: "Home Title", |
60 | | - body: "Home Body", |
61 | | - }); |
62 | | - |
63 | | - window.setTimeout(() => (toast.title = "Updated Home Title"), 1000); |
64 | | - } |
65 | | - |
66 | | - persistentToast() { |
67 | | - this.toasterService |
68 | | - .popAsync({ |
69 | | - type: "customtype" as ExtendedToastType, |
70 | | - title: "Click Me", |
71 | | - body: "I am sticky with a really long body let us see what happens", |
72 | | - tapToDismiss: false, |
73 | | - onClickCallback: (t) => console.log(t.toastId), |
74 | | - showCloseButton: true, |
75 | | - }) |
76 | | - .subscribe((x) => console.log(x)); |
77 | | - } |
78 | | - |
79 | | - ngAfterViewInit() { |
80 | | - console.log("entering view init"); |
81 | | - const t = "bad value"; |
82 | | - const toast: Toast = { |
83 | | - type: t as ExtendedToastType, |
84 | | - body: "I am init toast", |
85 | | - }; |
86 | | - this.toasterService.popAsync(toast); |
87 | | - } |
88 | | - |
89 | | - toto() { |
90 | | - console.log("todo button clicked"); |
91 | | - const toast: Toast = { |
92 | | - type: "success", |
93 | | - body: "I am todo toast", |
94 | | - timeout: 5000, |
95 | | - progressBar: true, |
96 | | - }; |
97 | | - this.toasterService.pop(toast); |
98 | | - } |
99 | | - |
100 | | - clear() { |
101 | | - this.toasterService.clear(); |
102 | | - } |
| 11 | +export class AppComponent { |
| 12 | + |
103 | 13 | } |
0 commit comments