中创建(或访问)所选行数组a>?How do I create (or access) an array of selected rows in my ng-grid?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 index.html<body ng-controller="MyCtrl"> <div class="gridStyle" ng-grid="gridOptions"></div> <h3>Rows selected</h3> <pre>{{selectedItems}}</pre></body> main.js main.jsvar 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代码(并运行它)推荐答案根据该文档, selectedItems 应该是 $ scope.gridOptions 的属性,所以请尝试:Based on the doc, selectedItems should be a property of $scope.gridOptions, so try this:控制器$scope.gridOptions = { data: 'myData', selectedItems: [] }; HTML <pre>{{gridOptions.selectedItems}}</pre> 这篇关于从ng网格中获取选择的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-15 20:15