我正在使用angular-toastr并试图通过使用 toastr option 来防止重复的 toastr preventOpenDuplicates,但可能是它不起作用或者我做错了什么。
烤面包机:
toastr.error('test', 'open duplicate', {
closeButton: true,
tmeOut: 0,
preventOpenDuplicates:true,
progressBar: true
});
我正在使用angular-toastr并试图通过使用 toastr option 来防止重复的 toastr preventOpenDuplicates,但可能是它不起作用或者我做错了什么。
烤面包机:
toastr.error('test', 'open duplicate', {
closeButton: true,
tmeOut: 0,
preventOpenDuplicates:true,
progressBar: true
});
您告诉angular-toastr不显示重复项的方法是设置preventDuplicates为对象true内部toastrConfig。而不是在toastr.errororsuccess或任何开场白中。
因此,您的代码将如下所示:
app.controller('MainCtrl', function($scope, toastr, toastrConfig) {
toastrConfig.preventDuplicates = true;
toastrConfig.preventOpenDuplicates = true;
toastrConfig.progressBar = true;
toastrConfig.closeButton = true;
$scope.OpenToastr = function() {
toastr.error('test', 'open duplicate');
}
});
编辑:找到了!是版本!:)
版本 1.4.0
- 有了
preventOpenDuplicates您可以防止重复打开的吐司。
该功能被引入1.4.0并且您正在使用1.3.1.
工作的笨蛋(更新)
使用ng7-snack-bar。它有助于防止重复并在过渡时自动关闭。