2017-04-17 37 views

回答

1

你告诉angular-toastr不显示重复是由toastrConfig对象内部设置preventDuplicatestrue的方式。而不是在toastr.errorsuccess或任何关于此事的揭幕战。

因此,您的代码会是这个样子:

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'); 
    } 
}); 

编辑:找到了!这是版本! :)

angular-toastr > CHANGELOG

版本1.4.0

  • 随着preventOpenDuplicates可以防止打开祝酒词的重复。

的功能得到了在1.4.0介绍和你使用1.3.1

working plunker(更新)

+0

preventDuplicates工作在toastrConfig精细设置后,但它不是封闭后,再次打开同一toastr。 –

+0

'preventOpenDuplicates'在我的情况下是有用的,但它不起作用,让我更新我的问题。 –

+0

@gauravbhavsar更新回答:) – tanmay