2017-04-17 82 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