- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我正在进行的项目中,我正在按照项目负责人的要求实现开发人员通知系统。它的工作方式是,如果发生前端错误,开发团队会收到一封错误电子邮件。
但是,在我当前的实现中,我似乎有以下循环依赖:
$rootScope <- $http <- $exceptionHandler <- $rootScope
在下面的代码中:
(function() {
'use strict';
// Using .config to 'decorate' the exception handler.
angular.module('app').config(function($provide) {
$provide.decorator('$exceptionHandler', ['$delegate', '$http', dispatchErrorEmail]);
});
function dispatchErrorEmail($delegate, $http) {
return function (exception, cause) {
// Execute default implementation.
$delegate(exception, cause);
// Angular exceptions fail softly, but generate an error email.
var args = {
'exception': exception,
'cause': cause
};
$http.post('/api/admin/ErrorNotification', args);
};
}
})();
如您所见,有一个小问题:我实际上并没有使用$rootScope
以任何方式装饰我的$errorHandler
.
更重要的是,$provide.decorator
都不是或 $errorHandler
文档记录了 $rootScope
被隐式包含。
问题:
$rootScope
注入(inject)这项服务,对吗?$exceptionHandler
装饰以避免这种循环依赖?最佳答案
再四处看看——特别是在相关侧边栏上——让我找到了this answer .差不多,我必须使用 $injector
来获取我的 $http
服务的实例句柄。
(function() {
'use strict';
// Using .config to 'decorate' the exception handler.
angular.module('app').config(function($provide) {
$provide.decorator('$exceptionHandler', ['$delegate', '$injector', dispatchErrorEmail]);
});
function dispatchErrorEmail($delegate, $injector) {
return function (exception, cause) {
// Execute default implementation.
$delegate(exception, cause);
// Angular exceptions fail softly, but generate an error email.
var $http = $injector.get('$http');
var args = {
'exception': exception,
'cause': cause
};
$http.post('/api/admin/ErrorNotification', args);
};
}
})();
这并不能解释为什么 $rootScope
会潜入$exceptionHandler
服务;我想我只需要相信它确实如此。
关于javascript - 装饰 $errorProvider 时的循环引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29289187/
我使用一个ErrorProvider errorProvider.SetIconAlignment(btnOk, ErrorIconAlignment.BottomLeft); error
我想知道我的表单中是否有任何 ErrorProvider 处于事件状态。能够找到这个可能有助于减少我的代码.. 我确实在这里找到了这个东西 Counting ErrorProvider 但以防万一有人
在下面的代码中我使用了errorProvider.SetError(control, message)来显示消息,但是只显示了Icon,没有显示消息,what错了吗? 有没有办法只调整错误消息的左边距
我正在尝试编写一些东西,在输入用户名/密码之前通过错误提供程序通知用户大写锁定已打开。我发现了一些看起来像这样的代码: private void nameInputTextBox_TextChange
我们使用派生的表单类,为我们的软件提供一个基本表单类。 在派生表单上,我们广泛使用 DataBinding 来处理我们的 BusinessObjects,所有这些都实现了 IDataErrorInfo
我对使用验证还很陌生。我有一个 C# winform 项目,我想在关闭之前验证一个表单。但是,我只希望在单击按钮时进行此验证。所以我有一个像这样触发的事件: if (!this.ValidateChi
在我正在进行的项目中,我正在按照项目负责人的要求实现开发人员通知系统。它的工作方式是,如果发生前端错误,开发团队会收到一封错误电子邮件。 但是,在我当前的实现中,我似乎有以下循环依赖: $rootSc
我有这段代码可以在发布记录之前进行一些基本的健全性检查: if (string.IsNullOrWhiteSpace(textBoxFirstName.Text)) { errorProvid
在 ErrorProvider 控件中我们可以使用 SetIconPadding();为了设置要在图标和控件之间添加的像素数。 这样我们就可以水平移动图标了。 如何在垂直方向上做同样的事情? 我不知道
为什么当我第一次来到我的窗口时,它是一个用户控件和组合框设置为空白的窗体。我可以毫无问题地单击取消并关闭窗口。但是,如果我触摸组合框然后将其留空并尝试单击取消取消事件不会触发? 最佳答案 你真正需要的
有谁知道是否有办法获得激活 ErrorProvider 图标的控件列表。 IE。验证失败的任何控件。我试图避免循环表单中的所有控件。 我想显示某种消息,指示表单上有多少错误。由于我的表单包含选项卡,因
我有一个问题。我验证了两个文本框。如果 texbox 未通过验证,我将显示带有错误提供程序的错误消息。 情况: tbAzetId.Text="字符串";tbHeslo.Text=空; errorpro
我有 10 个文本框,现在我想检查单击按钮时它们是否为空。 我的代码是: if (TextBox1.Text == "") { errorProvider1.SetError(TextBo
我有一个包含TabControl和ErrorProvider的窗体。选项卡中的一个具有多个文本框和一个按钮。如果内容无效,则文本框将对Validate事件使用SetError()。当按下按钮时,它将运
我的问题: ErrorProvider 生成的红色图标闪烁 6 次。我希望能够将它设置为闪烁两次。 我遇到的唯一闪烁属性是 BlinkRate 和 BlinkStyle,它们都不影响闪烁量。 重现:
我的问题: ErrorProvider 生成的红色图标闪烁 6 次。我希望能够将它设置为闪烁两次。 我遇到的唯一闪烁属性是 BlinkRate 和 BlinkStyle,它们都不影响闪烁量。 重现:
我正在努力将 errorprovider 扩展到 propertygrid 和 treeview 控件。我在以下位置找到了一个非常有用的帖子:Example 详细介绍了如何将错误提供程序添加到属性网格
我正在制作一个扩展方法库以在 Windows 窗体应用程序中使用。我打算创建的方法之一将使在输入控件上设置错误状态更容易,例如 public static void SetError(this Sys
我们使用 BusinessObjects,实现 IDataErrorInfo 和 IEditableObject。带有这些对象的 BindingList 被添加到 BindingSources,它们用
如果我在这里忽略了一些明显的东西,我深表歉意。 问题背景 我有一个允许用户填写表格的应用程序,其内容将被上传到数据库。当他们点击“上传”按钮时,必须验证表单。如果任何字段无效,将提醒用户。 当前解决方
我是一名优秀的程序员,十分优秀!