加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 09:41:57 所属栏目:安全 来源:网络整理
导读:如何在 ng-grid中创建(或访问)所选行数组? Documentation(滚动到“网格选项”) id | default value | definition-----------------------------------------------selectedItems | [] | all of the items selected in the grid. In single select mode ther
如何在 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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读