-->

“10个$ digets()迭代达到了”从NG-翻译错误处理程序试图$ http.post()的时候

2019-10-21 21:57发布

我们使用的角度转换来处理一个网站的本地化,使用我们从服务器获取翻译自定义加载程序。 在服务器端,我们有一个处理漏译键,以便我们俩返回的东西(从回退语言或密钥本身翻译),并报告给请求的关键系统逻辑(所以它显示在翻译UI其他地方的网站)。 现在,我用建立在客户端类似的东西挣扎。

$translateProvider有一个方法useMissingTranslationHandler(factory) ,我们已经成功地配置到刚刚注销,一个关键的缺失到控制台,使用如下:

app.config(function ($translateProvider) {
    $translateProvider.useMissingTranslationHandler('translationMissingHandler');
});

app.factory('translationMissingHandler', translationMissingHandler);

translationMissingHandler.$inject = ['$window', '$log', '$http'];
function translationMissingHandler($window, $log, $http) {
    return function (translationId) {
        var culture = $window.preferredCulture, // workaround for another problem
            errorInfo = {
                key: translationId,
                culture: culture
            };
        $log.warning('Translation missing:', errorInfo);
        // $http.post('/api/v2/localization/missing', errorInfo);
    }
}

不过,后来我取消注释POST到服务器,通知关于失踪键,网页挂在的14394行angular.js - throw e ,其中e.message

[$ rootScope:infdig] 10 $摘要()的迭代为止。 中止! 观察家在过去的5次迭代解雇:[]

我已经试过各种事情来解决这个问题-例如,呼叫包装到$http.post()$timeout$rootScope.$apply但无济于事; 我仍然得到同样的错误消息。

有没有一种方法来安排一次通话$http.post()从这里开始,而不会造成这个错误? 如果是这样,怎么样?

文章来源: “10 $digets() iterations reached” when trying to $http.post() from ng-translate error handler