2014-10-29 70 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