AlertComponent displays an alert message of type 'success' or 'danger' with customizable options.
It can automatically hide after a set duration and includes a manual dismiss option.
Selector
app-alert-component
Standalone
true
Imports
CommonModule
Inputs
visible (boolean): Determines if the alert is visible. Default is false.
message (string): The message displayed in the alert.
type ('success' | 'danger'): Type of alert, either 'success' or 'danger'. Default is 'success'.
duration (number): Duration in milliseconds for the alert to remain visible before hiding. Default is 4000 ms.
textColor (string): Optional color for alert text. Default is 'black'.
onHide (function): Optional callback invoked when the alert is hidden.
Methods
ngOnChanges(changes: SimpleChanges): Lifecycle hook invoked on input changes; initiates auto-hide based on duration if visible is true.
handlePress(): Manually hides the alert by invoking the onHide callback.
A callback method that is invoked immediately after the
default change detector has checked data-bound properties
if at least one has changed, and before the view and content
children are checked.
AlertComponent displays an alert message of type 'success' or 'danger' with customizable options. It can automatically hide after a set duration and includes a manual dismiss option.
Selector
app-alert-component
Standalone
true
Imports
CommonModule
Inputs
visible
(boolean): Determines if the alert is visible. Default is false.message
(string): The message displayed in the alert.type
('success' | 'danger'): Type of alert, either 'success' or 'danger'. Default is 'success'.duration
(number): Duration in milliseconds for the alert to remain visible before hiding. Default is 4000 ms.textColor
(string): Optional color for alert text. Default is 'black'.onHide
(function): Optional callback invoked when the alert is hidden.Methods
ngOnChanges(changes: SimpleChanges)
: Lifecycle hook invoked on input changes; initiates auto-hide based on duration ifvisible
is true.handlePress()
: Manually hides the alert by invoking theonHide
callback.Example