【问题标题】:Error: $rootScope:inprog Action Already In Progress mvc with angularjs错误:$rootScope:inprog 操作已经在进行中 mvc 与 angularjs
【发布时间】:2017-10-28 04:03:06
【问题描述】:

我正在使用带有 angularjs 的 mvc 创建一个 Web 应用程序,

我正在尝试在我的数据库中插入记录,但出现以下错误

错误:[$rootScope:inprog] http://errors.angularjs.org/1.6.4/$rootScope/inprog?p0=%24digest 在 angular.js:38 在 n (angular.js:18524) 在 m.$apply (angular.js:18259) 在 HTMLAnchorElement。 (angular.js:26999) 在 HTMLAnchorElement.dispatch (jquery-3.1.1.js:5201) 在 HTMLAnchorElement.elemData.handle (jquery-3.1.1.js:5009) 在 Object.trigger (jquery-3.1.1.js:8171) 在 HTMLAnchorElement。 (jquery-3.1.1.js:8239) 在 Function.each (jquery-3.1.1.js:368) 在 jQuery.fn.init.each (jquery-3.1.1.js:157)

这就是我的代码的样子

    $scope.insertdata = function () {
        $scope.students = {};
        $scope.students.name = $scope.stdname;
        $scope.students.fullname = $scope.stdfname;
        $scope.students.address = $scope.stdaddress;
        $scope.students.city = $scope.stdcity;
        $scope.students.country = $scope.stdcountry;
        $scope.students.contno = $scope.stdcontno;
        $http({
            method: "post",
            url: "/dashboardquot/insert_employee",
            datatype: "json",
            contentType: "application/json",
            data: $scope.students
        }).then(function (response) {
            angular.element('#closemodel').trigger('click');
        })
    }

正在插入数据,但仍然出现此错误 这段代码有什么问题?

【问题讨论】:

  • getdata() 在做什么?那个代码在哪里?
  • @rrd 更新了我的问题

标签: javascript jquery angularjs asp.net-mvc


【解决方案1】:

下面一行导致错误:

angular.element('#closemodel').trigger('click');

这是因为 click 事件绑定到一些导致多次调用 $digest 的代码。尝试将这一行包装在 $timeout 中。

【讨论】:

  • 感谢您的工作,如果您认为值得,请支持我的问题
猜你喜欢
  • 2014-10-01
  • 2016-07-18
  • 2014-05-09
  • 2014-03-18
  • 2023-03-28
  • 1970-01-01
  • 1970-01-01
  • 2016-07-15
  • 2015-04-08
相关资源
最近更新 更多