Tôi cần chức năng này để hiển thị bảng điều khiển khi có ít nhất 1 hàng được chọn. Ban đầu tôi thiết lập một chiếc đồng hồ, nhưng quyết định đó là quá đắt.
Tôi đã kết thúc thêm một cuộc gọi lại bên trong chỉ thị 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
});
});
//***///
}
};
});
tôi sau đó có thể vượt qua một chức năng từ bộ điều khiển của tôi để chỉ thị (lưu ý: bạn có thể vượt qua các hàng đã chọn lại, tôi không cần phải)
tr ng-repeat="row in customerResultsTable" st-select-row="row" st-select-mode="multiple" st-selected="rowSelected()">
Được tham chiếu bài này giúp Callback function inside directive attr defined in different attr
Nguồn
2015-02-18 15:12:03
Có thể điều này sẽ giúp bạn: https://github.com/lorenzofox3/Smart-Table/issues/21 – Xavjer