angularjs – 从ng网格中获取选择的行?

如何在 ng-grid中创建(或访问)所选行数组?

Documentation(滚动到“网格选项”)

id                 | default value | deFinition
-----------------------------------------------
selectedItems      |       []      | all of the items selected in the grid.
                                     In single select mode there will only
                                     be one item in the array.

的index.html

<body ng-controller="MyCtrl">
    <div class="gridStyle" ng-grid="gridOptions"></div>

    <h3>Rows selected</h3>
    <pre>{{selectedItems}}</pre>
</body>

main.js

var app = angular.module('myApp',['ngGrid']);
app.controller('MyCtrl',function($scope) {
    $scope.myData = [{name: "Moroni",age: 50},{name: "Tiancum",age: 43},{name: "Jacob",age: 27},{name: "Nephi",age: 29},{name: "Enos",age: 34}];
    $scope.gridOptions = { data: 'myData' };
});

Plnkr for the code(并运行它)

根据文档,selectedItems应该是$scope.gridOptions的属性,所以尝试这样做:

调节器

$scope.gridOptions = { data: 'myData',selectedItems: [] };

HTML

<pre>{{gridOptions.selectedItems}}</pre>

相关文章

ANGULAR.JS:NG-SELECTANDNG-OPTIONSPS:其实看英文文档比看中...
AngularJS中使用Chart.js制折线图与饼图实例  Chart.js 是...
IE浏览器兼容性后续前言 继续尝试解决IE浏览器兼容性问题,...
Angular实现下拉菜单多选写这篇文章时,引用文章地址如下:h...
在AngularJS应用中集成科大讯飞语音输入功能前言 根据项目...
Angular数据更新不及时问题探讨前言 在修复控制角标正确变...