我正在使用角度应用程序,并且如果条件被验证,我想使用sweetalert显示警报,因此如何在不使用单击按钮的情况下执行此操作
我曾尝试这样做,但是没有用
<div *ngIf="Users.length == 0" [swal]="showSwal">
<swal #showSwal
title=" No Data "
text="No data To Show"
showCloseButton="true"
type="warning">
</swal>
</div>
通常Sweetalert在这样的按钮中称呼小牛皮简单的例子:
<swal
#deleteSwal
title="Delete {{ file.name }}?"
text="This cannot be undone"
type="question"
[showCancelButton]="true"
[focusCancel]="true"
(confirm)="deleteFile(file)">
</swal>
With [swal]:
<button [swal]="deleteSwal">Delete {{ file.name }}</button>
就我而言,我想在部门中致电警报。
感谢
从变量名“ Users”来看,它可能是可观察的或@Input()。因此,如果可以观察到,则在其subscription方法中编写showSwal.fire()。如果它是@Input(),则可以在ngOnChanges()生命周期挂钩上编写它。