【问题标题】:Getting infinite loop in angular js controller, Uncaught Error: [$rootScope:infdig]在角度 js 控制器中获取无限循环,未捕获的错误:[$rootScope:infdig]
【发布时间】:2016-03-22 15:50:12
【问题描述】:

JSP(部分代码)

<tr ng-repeat="eachlowerstack in configdata.lowerstack">
    <td>
        <p ng-model="detail(eachlowerstack.integration.id)">{{eachlowerstack.integration.id}}</p><br>
        <span>Name: {{config.name}}</span><br>
        <span>Platform: {{config.platform}}</span><br>
        <span>Version: {{config.version}}</span><br>
        <span>Level: {{config.level}}</span><br>
    </td>

控制器:

$scope.detail = function(integid) {


    $scope.url1 = contextPath + "/getlowerstackdetails/"+integid;
    console.log($scope.url1);

    DependecyInject.getData($scope.url1).then(function(result) {
        $scope.config = result.data;
        console.log($scope.config);
        console.log($scope.config.name);
        console.log($scope.config.platform);
        console.log($scope.config.version);
        console.log($scope.config.level);
        //console.log($scope.configdata.lowerstack.integration.id);
    });
};

在运行时,我从后端得到响应,但它进入了无限循环:

angular.js:38 未捕获的错误:[$rootScope:infdig] http://errors.angularjs.org/1.5.0/$rootScope/infdig?p0=10&p1=%5B%5D

【问题讨论】:

  • 你的ngModel 是一个函数——你希望它做什么?
  • 我看不到您正在循环 ng-repeat 的 configData.lowerstack 变量
  • configdata.lowerstack 是一个 json 数组,其中有多个 integration.id ,对于每个 integration.id 我想要通过

    {{eachlowerstack.integration.id}}

    将此参数发送到我正在执行的控制器,然后从控制器进行其余的 api 调用并获得响应(因此目前它能够拨打电话但进入无限循环)

标签: jquery angularjs html


【解决方案1】:

使用“ng-init”代替“ng-model”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-18
    • 1970-01-01
    • 2023-03-24
    • 2016-12-13
    • 1970-01-01
    • 2016-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多