这是一个示例 plunker: http ://plnkr.co/edit/9iCNie?p=preview
预计 myData 在名称被编辑后会发生变化,但事实并非如此。
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,以防这是一个错误。