Basic usage
Create the alert UI
The DaisyUI library provides a nice looking UI for a alert
component that can be used to display a message to the user.
Instructions
-
Update the template of
alert-banner.component.ts
file:<div role="alert" class="alert alert-vertical alert-info alert-soft"><span>12 unread messages. Tap to see.</span><div><button class="btn btn-sm">Deny</button><button class="btn btn-sm btn-primary">Accept</button></div></div>
Display the component
Let’s now display the banner in the TaskList
and TaskForm
components.
Instructions
-
Update the template of
task-list.component.ts
file:<app-alert-banner /> -
Import the
AlertBannerComponent
in thetask-list.component.ts
file:import { AlertBannerComponent } from "../alert-banner/alert-banner.component";And add it to the
@Component
decorator’simports
array:@Component({selector: "app-task-list",templateUrl: "./task-list.html",styleUrls: ["./task-list.css"],imports: [AlertBannerComponent],}) -
Update the template of
task-form.component.ts
file:<app-alert-banner /> -
Import the
AlertBannerComponent
in thetask-form.component.ts
file:import { AlertBannerComponent } from "../alert-banner/alert-banner.component";And add it to the
@Component
decorator’simports
array:@Component({selector: "app-task-form",templateUrl: "./task-form.html",styleUrls: ["./task-form.css"],imports: [AlertBannerComponent],}) -
Test the application.
You should see the banner displayed in both components.