2014-10-29 65 views
1

我使用ngHandonstable指令,並在我看來,結合數據顯示如下:綁定數據,查看使用ngHandsontable

<div class="col-sm-9" id="plastic" ng-cloak ng-init="dataLoad()"> 
<hot-table settings="{colHeaders: colHeaders, contextMenu: ['row_above', 'row_below', 'remove_row'], afterChange: afterChange, fillhandle : fillHandle}" 
      rowheaders="true" minsparerows="minSpareRows" datarows="db.lens" height="300" width="700"> 
    <hot-column data="code" title="'Code'" type="grayedOut" readonly></hot-column> 
    <hot-column data="description" title="'Description'" width="250" type="grayedOut" readonly></hot-column> 
    <hot-column data="lastCost" title="'Previous Price'" type="grayedOut" readonly width="100"></hot-column> 
    <hot-column data="currentCost" title="'Current Price'" type="'numeric'" width="100" format="'0,0.00 '"></hot-column> 
    <hot-column data="percentageChange" title="'% Increase'" type="'numeric'" width="120" format="'% 0,0.00'" fillhandle="vertical"></hot-column> 
</hot-table> 

在我的控制,我有下面這段代碼:

app.controller('plasticController', ['$scope', '$location', 'toaster', 'plasticService', function ($scope, $location, toaster, plasticService) { 
    $scope.minSpareRows = 0; 
    $scope.colHeaders = true; 
    $scope.fillHandle = true; 

    $scope.db = []; 
    var dataLoad2 = function() { 
     plasticService.getPlastic().then(function(results) { 
      $scope.db = results.data; 
      $scope.totalItems = results.totalCount; 
      $scope.currentPage = results.currPage; 
      $scope.totalPages = results.totalPages; 

     }, function(error) { 
      //alert(error.data.message); 
     }); 
    }; 

我的看法不顯示來自我的控制器的任何數據。當異步調用完成json數據時,如何將數據推送到用戶界面?

回答

2

屬性數據行應該是DB不db.lens因爲你擁有它目前

datarows="db" 
+0

@Sithelo恩圭尼亞答案看起來是正確的給我。請接受它,如果它爲你工作。 – 2016-09-02 11:41:57