如何在AngularJS onclick按钮中刷新ng-repeat表?

时间:2018-01-18 09:35:48

标签: javascript jquery html angularjs angularjs-ng-repeat

我无法以任何方式使用ng-repeat更新表中字段的值,无论是使用$ scope.apply()还是使用超时。 这是我的HTML代码:

<div class="container">
   <table class="table" id="table">
      <thead class="table-bordered">
         <th ng-repeat="(column_name,v) in response[0];">{{column_name}}<br>
            <b>Class:</b>
            <a ng-click="chooseClass(column_name)"  id="{{column_name + 1}}">
            {{kls_dict[column_name][0]}}
            </a>
            <br>
            <b>Transfs:</b>
            <a ng-click="chooseTrf(column_name)" id="{{column_name + 2}}">
            {{kls_transfs[kls_dict[column_name][0]][0]}}
            </a>
         </th>
      </thead>
      <tbody>
         <tr ng-repeat="row in response">
            <td ng-repeat="value in row">{{value}}</td>
         </tr>
      </tbody>
   </table>
</div>

这是我在另一个HTML按钮组件中调用的JS函数:

$scope.save_params = function (old_transformation, object) {

    console.log("Enter save_params");
    console.log("trfs", old_transformation)
    console.log(object)
    console.log('class', $rootScope.old_class)
    console.log('columns_name', $rootScope.show_column_name)
    to_send = {
        'class': $rootScope.old_class,
        'column_name': $rootScope.show_column_name,
        "trfs": old_transformation,
        "params": object
    }
    $rootScope.spm.close();
    $http({
        url: "/send_parameters",
        method: "POST",
        headers: {'Content-Type': 'application/json'},
        data: JSON.stringify(to_send)
    }).success(function (data) {
        console.log(data)
    }).error(function () {
        console.error('Errore durante invio dei parametri');
        $("#warning-alert").text("Errore durante l'invio dei parametri, riprovare o controllare i parametri specificati");
        $("#warning-alert").fadeTo(2000, 500).slideUp(500, function () {
            $("#warning-alert").slideUp(500);
        });
    });
};

我已经指定了AngularJS控制器。谢谢大家:)

0 个答案:

没有答案