数据表未在 angularjs 中重新加载
Datatables not reloading in angularjs
我有一个要求,我必须将特定产品添加到数据table 并重新绑定数据table,以便更新其计数。我正在使用 MVC 和 angularjs 1.6.2
我正在创建数据table,如下所示:
<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>
视图上有一个部分包含用于获取产品名称的文本框和用于获取产品的下拉菜单 type.It 还包含一个 Add 按钮,单击该按钮在服务器上点击 post 以保存该产品,在前端 post 成功后,我调用函数重新加载 AllProducts
。一旦调用该函数,我就会收到错误
TypeError: o.ngDestroy is not a function in angularjs dataTables.
在 table
中保存产品后,通过以下代码重新加载数据table
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。如果需要,我可以提供更多详细信息。谢谢
我找到了解决方法。由于它导致了问题,我懒洋洋地绑定了图书馆。通过将加载部分放在 setTimeout 中,它就像一个魅力
我有一个要求,我必须将特定产品添加到数据table 并重新绑定数据table,以便更新其计数。我正在使用 MVC 和 angularjs 1.6.2
我正在创建数据table,如下所示:
<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>
视图上有一个部分包含用于获取产品名称的文本框和用于获取产品的下拉菜单 type.It 还包含一个 Add 按钮,单击该按钮在服务器上点击 post 以保存该产品,在前端 post 成功后,我调用函数重新加载 AllProducts
。一旦调用该函数,我就会收到错误
TypeError: o.ngDestroy is not a function in angularjs dataTables.
在 table
中保存产品后,通过以下代码重新加载数据tablevar 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。如果需要,我可以提供更多详细信息。谢谢
我找到了解决方法。由于它导致了问题,我懒洋洋地绑定了图书馆。通过将加载部分放在 setTimeout 中,它就像一个魅力