加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS Smarttable – 选择事件

发布时间:2020-12-17 07:17:11 所属栏目:安全 来源:网络整理
导读:有没有办法在AngularJS智能表中的行选择上触发事件? 这是其他主题的主题,但仍然没有回答这一点. Unable to select the grid item using SmartTable in Angular JS 解决方法 我需要此功能,以便在选择至少1行时显示面板.我最初设置了一块手表,但决定这太贵了.
有没有办法在AngularJS智能表中的行选择上触发事件?

这是其他主题的主题,但仍然没有回答这一点.

Unable to select the grid item using SmartTable in Angular JS

解决方法

我需要此功能,以便在选择至少1行时显示面板.我最初设置了一块手表,但决定这太贵了.

我最终在stSelectRow指令中添加了一个回调.

ng.module('smart-table')
  .directive('stSelectRow',function () {
    return {
      restrict: 'A',require: '^stTable',scope: {
          row: '=stSelectRow',callback: '&stSelected' // ADDED THIS
      },link: function (scope,element,attr,ctrl) {
        var mode = attr.stSelectMode || 'single';
        element.bind('click',function ($event) {
          scope.$apply(function () {
              ctrl.select(scope.row,mode,$event.shiftKey);
              scope.callback(); // AND THIS
          });
        });

        //***///
      }
    };
  });

然后我能够将一个函数从我的控制器传递给指令(注意:你可以传回选定的行,我不需要)

tr ng-repeat="row in customerResultsTable" st-select-row="row" st-select-mode="multiple" st-selected="rowSelected()">

在这篇文章中引用了帮助Callback function inside directive attr defined in different attr

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读