Angular ng-grid editableCellTemplate抛出异常

Kla*_*urn 3 javascript angularjs ng-grid

我正在尝试editableCellTemplate在ng-grid中设置ColumnDef选项(此处记录).

当我设置它时,即使是默认值<input ng-class="'colt' + col.index" ng-input="COL_FIELD" />,单击一个单元格会立即显示错误

错误:没有控制器:ngModel处getControllers(错误()http://foo.com:43037/Scripts/angular.js:4232:19在nodeLinkFn)(http://foo.com:43037/Scripts/angular. js:4361:35)在compositeLinkFn(http://foo.com:43037/Scripts/angular.js:3969:15)的compositeLinkFn(http://foo.com:43037/Scripts/angular.js:3972: 13)at object的publicLinkFn(http://foo.com:43037/Scripts/angular.js:3874:30).(http://foo.com:43037/Scripts/ng-grid-2.0.7.js:2660:13)在Object.Scope的Object.applyFunction [as fn](​​:778:50).$ digest(http ://foo.com:43037/Scripts/angular.js:7896:27)at Object.$ delegate.proto.$ digest(:844:31)<input ng-class ="'colt'+ col.index"ng-input ="row.entity.Name">

如果我没有设置editableCellTemplate,编辑单元格就可以了.

$scope.gridOptions = {
    data: 'people',
    enableCellSelection: true,
    enableRowSelection: false,
    enableCellEdit: true,
    columnDefs:
    [
        { field: 'Id', displayName: 'ID', enableCellEdit: false },
        { field: 'Name', enableCellEdit: true, 
          editableCellTemplate: '<input ng-class="\'colt\' + col.index" ng-input="COL_FIELD" />' }
    ]
};
Run Code Online (Sandbox Code Playgroud)

怎么了?

(我实际上试图解决的问题是在单元格编辑结束时创建一个事件,但该解决方案假定您可以设置一个单元格模板)

Dav*_*yon 8

input需要ng-model定义属性的模板:

<input ng-class="'colt' + col.index" ng-input="COL_FIELD" ng-model="COL_FIELD" />
Run Code Online (Sandbox Code Playgroud)

这是默认值 editableCellTemplate.

  • 这很好用,谢谢.我得到的"默认"值是从API文档http://angular-ui.github.io/ng-grid/#api中复制粘贴的,它缺少ng-model属性.对我来说看起来像文档错误. (3认同)