簡體   English   中英

angularJs-看不到烤面包機錯誤

[英]angularJs - Can not see toastr error displayed

我花了幾個小時解決這個問題,但我無法解決:(我知道大約一個星期前我已經測試了該功能,並且看到了2條Toastr錯誤消息(不過,我不希望有兩個錯誤消息)。我不確定到底發生了什么變化,但是現在我什至無法顯示一個:(我完全看不到烤面包機消息。

我的代碼是:

 app.directive('serverError', ['resourceFactory', 'spinnerService', 'toastr', '$log', function (resourceFactory, spinnerService, toastr, $log) { return { restrict: 'A', controller: ['$scope', '$timeout', function ($scope, $timeout) { log = $log.getInstance("serverError"); var errorToastConfig = { closeButton: true, timeOut: 0, extendedTimeOut: 0, tapToDismiss: false, preventDuplicates: true }; var title = resourceFactory.getResource("Messages", "applicationError"); $scope.$on('sm:badRequest', function (event, data) { if (!$scope.errorHandled && !$scope.showForm) { log.debug("Handling bad request"); let errorMsg = ""; angular.forEach(data, function (value, key) { if (value.message == '') value.message = 'The ' + value.property + ' value is invalid.' errorMsg = errorMsg + value.message + " "; }); errorMsg = errorMsg.trim(); $scope.errors = data; toastr.clear(); if (errorMsg=="") errorMsg = resourceFactory.getResource('Messages', 'errorOnForm'); title = resourceFactory.getResource("Messages", "badRequest"); toastr.error(errorMsg, title, errorToastConfig); } $scope.disableAction = false; }); 

然后也在控制器中:

 function (error) { spinnerService.stopSpinner('loaditemtree'); $scope.stopExecution = true; if (error.hasOwnProperty("data")) { toastr.clear(); let errorMsg = error.data[0].message; toastr.error(errorMsg); } }); 

我在控制台中看到[ItImagesSearchController]圖片搜索控制器的初始化正在觸發... / SiriuswareControl / api / itDraftHeaders / 1019無法加載資源:服務器響應狀態為400(錯誤請求)2angular.js:14525 [ serverError]處理錯誤的請求

我還在控制器中跟蹤了我的代碼,並且可以看到執行了toastr的那一行。 但是,我看不到烤面包機:(可能有什么問題嗎?

我相信我已經解決了,但是我有點回到第1步了。我想防止顯示重復的Toastr消息,因此我在服務器錯誤Toastr配置中具有了preventDuplicates:true。 但是,它以某種方式使任何消息都無法顯示。 當我在控制器中稍稍更改了消息時,我現在看到了兩個烤面包機消息。 如何只顯示其中之一?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM