我是Angular JS的新手。下面的代碼不起作用。我已經嘗試過使用Ng-Repeat的數據表。但它只是顯示沒有任何排序的表格,分頁選項。吳重複和ng表問題
響應數據的樣子:
[{
\"ACCOUNT_LOCAL\":\"9007\",\"COMPANY_ID\":\"10001\",
\"ACCOUNT_GLOBAL\":\"100001\",\"IC_PARTNER\":\"9008\",
\"ACCOUNT_GLOBAL_DESC\":\"AUS GLOBAL\",
\"ACCOUNT_TYPE\":\"1\",\"COMPANY_DESC\":\"THIRDROCK\",
\"ACTIVE\":true
},
{
\"ACCOUNT_LOCAL\":\"9008\",\"COMPANY_ID\":\"10001\",
\"ACCOUNT_GLOBAL\":\"100001\",\"IC_PARTNER\":\"9009\",
\"ACCOUNT_GLOBAL_DESC\":\"AUS GLOBAL\",
\"ACCOUNT_TYPE\":\"1\",\"COMPANY_DESC\":\"THIRDROCK\",
\"ACTIVE\":true
},{
\"ACCOUNT_LOCAL\":\"9014\",\"COMPANY_ID\":\"10001\",
\"ACCOUNT_GLOBAL\":\"100001\",\"IC_PARTNER\":\"TEST\",
\"ACCOUNT_GLOBAL_DESC\":\"AUS GLOBAL\",
\"ACCOUNT_TYPE\":\"1\",\"COMPANY_DESC\":\"THIRDROCK\",
\"ACTIVE\":true
},
HTML文件
<div ng-app="myApp" ng-controller="AccountMappingCtrl as vm">
<table ng-table="vm.tableParams" show-filter="true" class="table">
<tr ng-repeat="accountMap in $data">
<td title="'IC_PARTNER'" filter="{ IC_PARTNER: 'text'}" sortable="'IC_PARTNER'">
{{ accountMap.IC_PARTNER }}
</td>
<td title="'ACCOUNT_GLOBAL'" filter="{ ACCOUNT_GLOBAL: 'text'}" sortable="'ACCOUNT_GLOBAL'">
{ accountMap.ACCOUNT_GLOBAL }}
</td>
</tr>
</table>
</div>
JS文件:
var app = angular.module('myApp', [ 'ngTable']);
app.controller('AccountMappingCtrl', ['$scope', '$http','$cookies', 'NgTableParams', function($scope, $http, $filter, NgTableParams) {
$http.get("http://localhost:52087/api/accountmapping")
.then(function(response) {
var convertJson = angular.fromJson(response.data);
var self = this;
var data = convertJson;
self.tableParams = new NgTableParams({}, { dataset: data});
});
});
你正在得到什麼錯誤? – Rahul
ngTableParams未定義 - 控制檯錯誤 –
應該是「新的NgTableParams」嗎? – Rahul