gpt4 book ai didi

AngularJS Smarttable - 选择事件

转载 作者:行者123 更新时间:2023-12-04 20:03:05 24 4
gpt4 key购买 nike

有没有办法在 AngularJS 智能表中的行选择上触发事件?

这是其他线程中的主题,但仍然没有答案。

Unable to select the grid item using SmartTable in Angular JS

最佳答案

我需要此功能以便在选择至少 1 行时显示面板。我最初设置了一个 watch ,但觉得太贵了。

我最终在 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
});
});

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

然后我就可以将一个函数从我的 Controller 传递给指令(注意:你可以将选定的行传回,我不需要)
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

关于AngularJS Smarttable - 选择事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28042128/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com