👁 View: stSelectRow.js
Path: /home/thiqat5/cargo.thiqatech.com/bower_components/angular-smart-table/src/stSelectRow.js
Size: 685 B · Modified: 2015-02-09 13:00:00 · Perm: 0644 · Writable
ng.module('smart-table')
  .directive('stSelectRow', function () {
    return {
      restrict: 'A',
      require: '^stTable',
      scope: {
        row: '=stSelectRow'
      },
      link: function (scope, element, attr, ctrl) {
        var mode = attr.stSelectMode || 'single';
        element.bind('click', function () {
          scope.$apply(function () {
            ctrl.select(scope.row, mode);
          });
        });

        scope.$watch('row.isSelected', function (newValue) {
          if (newValue === true) {
            element.addClass('st-selected');
          } else {
            element.removeClass('st-selected');
          }
        });
      }
    };
  });