Frequently, there is a need to showcase multiple alerts, particularly those at the application level positioned at the top. The clr-lift offers two highly beneficial components for this purpose: AlertContainerComponent and AlertService. The service provides methods to add, delete, and clear alerts programmatically.
Examples
Example 1: Setup Alert Container
Import AlertContainerComponent and include <cll-alert-container> above the Clarity header tag within the main container.
Import AlertService and utilize its addAlert(), deleteAlert(), or clearAlerts() methods for effective management of alerts. The addAlert function takes an object as its parameter, with the content field being mandatory and representing the alert content in string format. Additionally, you have the option to include other properties, such as alertType, to specify the type of alert, and indicate whether it is an application-level alert through isAppLevel. The default value for isAppLevel is true, as in most cases, you would prefer to display multiple alerts at the application level.
Example 3: Advanced Usage with Interactive Elements
In certain scenarios, you may want to include a button or link within an alert's content. To handle button clicks or navigate to an internal route through link clicks, you can use the onTargetClick and targetSelector properties. The targetSelector represents the selector of the clickable element (ID, class, etc.), and the onTargetClick specifies the function to be executed upon clicking the element.