【问题标题】:Binding data to view using ngHandsontable使用 ngHandsontable 绑定数据以查看
【发布时间】:2014-12-25 04:27:51
【问题描述】:

我正在使用 ngHandonstable 指令和绑定数据,如下所示:

<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数据异步调用完成后,如何将数据推送到UI?

【问题讨论】:

    标签: angularjs angularjs-directive handsontable


    【解决方案1】:

    属性数据行应该是 db 而不是 db.lens,因为你现在拥有它

    datarows="db"
    

    【讨论】:

    • @Sithelo Ngwenya 答案对我来说是正确的。如果它对你有用,请接受它。
    猜你喜欢
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 2017-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-23
    相关资源
    最近更新 更多