以下是一个示例plunker:http://plnkr.co/edit/9iCNie?p=preview
在编辑名称后,我的数据会发生变化,但事实并非如此。
HTML:
<body ng-controller="MyCtrl">
{{myData}}
<div class="gridStyle" ng-grid="gridOptions"></div>
</body>
JS:
// 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',
enableCellSelection: true,
canSelectRows: false,
displaySelectionCheckbox: false,
columnDefs: [{field: 'name', displayName: 'Name', enableFocusedCellEdit: true}, {field:'age', displayName:'Age'}]
};
});
我在这里也打开了一个问题https://github.com/angular-ui/ng-grid/issues/182,以防这是一个错误。