我正在尝试使用行点击事件选择行对象。我正在使用 Angular UI Grid
以下是API链接 http://ui-grid.info/docs/#/tutorial/103_filtering
我用它来获取数据:
enableRowSelection: true,
multiSelect:false,
onRegisterApi : function(gridApi){
//set gridApi on scope
$scope.gridApi = gridApi;
gridApi.selection.on.rowSelectionChanged($scope,function(row){
var msg = 'row selected ' + row.isSelected;
$log.log(msg);
});
答案 0 :(得分:1)
将ui.grid.selection
注入您的应用模块:
angular.module('app',['ngTouch', 'ui.grid', 'ui.grid.selection'])
html上的设置选择:
<div id="grid1" ui-grid="gridOptions" ui-grid-selection class="grid" ></div>
使用row.entity
获取所选行对象:
gridApi.selection.on.rowSelectionChanged($scope,function(row){
var msg = 'row selected ' + row.entity.age;
console.log(msg);
});
工作人员: