I am currently working on an Angular application and I am trying to display an alert using SweetAlert if a certain condition is met. How can I achieve this without the need for a click button?
I attempted to implement the following code but it did not work as expected
<div *ngIf="Users.length == 0" [swal]="showSwal">
<swal #showSwal
title=" No Data "
text="No data To Show"
showCloseButton="true"
type="warning">
</swal>
</div>
Typically, SweetAlert is triggered by a button click, like in this simple example:
<swal
#deleteSwal
title="Delete {{ file.name }}?"
text="This cannot be undone"
type="question"
[showCancelButton]="true"
[focusCancel]="true"
(confirm)="deleteFile(file)">
</swal>
<!-- Using [swal]: -->
<button [swal]="deleteSwal">Delete {{ file.name }}</button>
However, in my scenario, I wish to trigger the alert within a div.
Thank you