2016-10-26 81 views
0

我决定将https://lorenzofox3.github.io/smart-table-website/纳入我的应用程序。在网站上的例子工作正常,但是,当我开始整合时,我无法做出行选择功能。智能表与角1.5.8 - 行选择不工作 - 范围未填写

演示网站和我之间的主要区别是我使用的是Angular 1.5.8。我已经调试并确定了片段,这让我怀疑:

ng.module('smart-table') 
    .directive('stSelectRow', ['stConfig', function (stConfig) { 
    return { 
     restrict: 'A', 
     require: '^stTable', 
     scope: { 
     row: '=stSelectRow' 
     }, 
     link: function (scope, element, attr, ctrl) { 
     var mode = attr.stSelectMode || stConfig.select.mode; 
     element.bind('click', function() { 
      scope.$apply(function() { 
      ctrl.select(scope.row, mode); 
      }); 
     }); 

     scope.$watch('row.isSelected', function (newValue) { 
      if (newValue === true) { 
      element.addClass(stConfig.select.selectedClass); 
      } else { 
      element.removeClass(stConfig.select.selectedClass); 
      } 
     }); 
     } 
    }; 
    }]); 

功能link接收scope对象,其中row是不确定的,因此select功能跳过,并没有什么对行所做的。

我已经在笔上复制了该问题:http://codepen.io/anon/pen/bwJqBw过滤器和排序工作正常,只有行选择不是。

我该如何解决问题以及原因是什么?范围绑定的语法是否已更改?根据文档,这似乎是好的,但作为一个角度新手,我很难断言。

回答

1

您需要使用ST-选择行使用的是在您的NG-重复相同的参考,从你的codepen,你正在做的:

<tr st-select-row="row" st-select-mode="multiple" ng-repeat="customer in displayedCustomers"> 

而且你应该做的:

<tr st-select-row="customer" st-select-mode="multiple" ng-repeat="customer in displayedCustomers">