错误:Angular 2 中的 [$rootScope:inprog]



页面上有一个X-Editable(自动完成(输入。当我激活它并按键盘上的 ArrowDown 或 ArrowUp 来选择一个人时,会出现第一个人,但也会出现"从列表中选择"提示,并且控制台中出现错误:http://joxi.ru/DmBlqXXsNjNpwA

信息.js:

updateRefField(data, fieldName, dictionaryName, projectType) {
    if (data !== null && !Number.isInteger(data*1)) {
        return this.$q.resolve('Choose from list');
    }
    return this.ProjectService.updateRefField(data, fieldName, dictionaryName, projectType || this.projectType)
        .then((res) => {
            if ((data === null) && ((fieldName === 'GorManager') || (fieldName === 'Manager')
                || (fieldName === 'Author') || (fieldName === 'ChiefDesigner') || (fieldName === 'ChiefDesignerAssistant'))) {
                var that = this;
                setTimeout(function() {
                    that.$scope.$apply(function() {
                        that.current[fieldName] = null;
                    });
                }, 4);
            }
            return this.$q.resolve(res.message || null);
        });
}

可编辑自动完成.js:

onshow: function () {
        var that = this;
        setTimeout(function () {
            $(that.editorEl.find('select').getKendoComboBox().input).focus();
            var oldValue = that.scope.$data;
            that.editorEl.find('select').getKendoComboBox().bind('change', function (e) {
                if (this.element.val()) {
                    that.scope.$data = this.dataItem() ? this.dataItem().Id : oldValue;
                } else {
                    that.scope.$data = null;
                }
            });
            that.editorEl.find('select').getKendoComboBox().bind('open', function (e) {
                $('.k-popup').on('click', function (event) {
                    event.stopPropagation();
                });
            });
            that.editorEl.find('select').getKendoComboBox().bind('filtering', function (e) {
                var filter = e.filter;
                if (!filter.value) {
                    e.preventDefault();
                }
            });
        }, 4);
    }

更新:已解决。在评论中添加了决定。

问题是,$digest已经在进行中。

尝试在that.$scope.$applyAsync(function() {中更改that.$scope.$apply(function() {

将选项返回到 select 的代码如下所示:

read: (options) => {
            EmployeesService.getEmployees(options.data, currentEmployeeId).then((employees) => {
                options.success(employees);
            });
        }

我添加了 setTimeout,代码更改为:

read: (options) => {
            EmployeesService.getEmployees(options.data, currentEmployeeId).then((employees) => {
                setTimeout(function() {
                    return options.success(employees);
                }, 4);
            });
        }

最新更新