gpt4 book ai didi

angularjs - 数据表未在 angularjs 中重新加载

转载 作者:行者123 更新时间:2023-12-02 04:29:12 24 4
gpt4 key购买 nike

我有一个要求,我必须将特定产品添加到数据表并重新绑定(bind)数据表,以便更新其计数。我正在使用 MVC 和 angularjs 1.6.2

我正在创建数据表,如下所示:

<table id="dtProducts" ng-if="AllProducts"
class="table manage-user-table offer-mgt-table market-selection-tab"
datatable="ng" dt-options="dataTableOpt">
<thead>
<tr>
<th><input type='checkbox' class="selectAllMarket"
value='SelectAll' ng-model="selectAll" >
</th>
<th>Product Name</th>
<th>Product Type</th>
</tr>
</thead>
<tbody>
<tr dt-rows ng-repeat="product in AllProducts">
<td><input type="checkbox" class="selectMarket"
ng-model="product.selected"
data-offerid="{{product.ID}}"
ng-click="toggleSelect(product.selected, $index)">
</td>
<td>{{product.Name}}</td>
<td>{{product.VerticalType.VerticalTypeDisplayName}}</td>

</tr>
</tbody>
</table>

View 上有一个部分,其中包含一个用于获取产品名称的文本框和一个用于获取产品类型的下拉列表。它还包含一个添加按钮,用于单击服务器上的帖子以保存该产品并成功在前端发布我调用函数来重新加载 AllProducts .一旦调用该函数,我就会得到错误

TypeError: o.ngDestroy is not a function in angularjs dataTables.



将产品保存在表中后,通过以下代码重新加载数据表
var getAllProducts = function () {
var urlgetAllProducts = apiURL + "/AllProducts?providerId=" + providerID;
$http({
url: urlgetAllProducts,
method: 'GET', //$scope.customization,
}).then(function successcallback(response) {

$scope.AllProducts = response.data.ResponseData;


$scope.$parent.AllProducts = $scope.AllProducts;
if ($scope.offer.ProductList != undefined) {

MakeSelected();
$scope.selectProducts();

}

},
function errorcallback(response) {
}).then(function () {
});
}

任何人都可以在这方面帮助我吗?我正在使用 angulardatatables 0.6.2。如果需要,我可以提供更多详细信息。谢谢

最佳答案

我找到了解决方案。我懒惰地绑定(bind)了导致问​​题的库。通过将加载部分放在 setTimeout 中,它就像一个魅力

关于angularjs - 数据表未在 angularjs 中重新加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50630946/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com