选中 ui-grid angular js 中的复选框

Checked the check box in ui-grid angular js

在我的项目中使用 ui-grid,我从数据库中获取 JSON 对象,如下面的

[
    {
        "checkbox1": {
            "fieldName": "checkbox1",
            "fieldValue": "Y"
        },
        "checkbox2": {
            "fieldName": "checkbox3",
            "fieldValue": "Y"
        },
        "checkbox3": {
            "fieldName": "checkbox3",
            "fieldValue": "N"
        }
    }
]

下面的对象是 columnDef

[
    {
        "name": "checkbox1",
        "field": "checkbox1.fieldValue",
        "displayName": "checkbox1",
        "cellTemplate": '<input type=\"checkbox\" ng-model=\"{{COL_FIELD}}\" ng-true-value=\'Y\' ng-false-value=\'N\' />'
    },
    {
        "name": "checkbox2",
        "field": "checkbox2.fieldValue",
        "displayName": "checkbox2",
        "cellTemplate": '<input type=\"checkbox\" ng-model=\"{{COL_FIELD}}\" ng-true-value=\'Y\' ng-false-value=\'N\' />'
    },
    {
       "name": "checkbox3",
        "field": "checkbox3.fieldValue",
        "displayName": "checkbox3",
        "cellTemplate": '<input type=\"checkbox\" ng-model=\"{{COL_FIELD}}\" ng-true-value=\'Y\' ng-false-value=\'N\' />'
    }
];

渲染 html 后,控制台出现错误:

Error: [$parse:syntax] http://errors.angularjs.org/1.5.0-rc.1/$parse/syntax?p0=%7B&p1=invalid%20key&p2=2&p3=%7B%7Bgrid.getCellValue(row%2Col)%7D%7D&p4=%7Bgrid.getCellValue(row%2C%col)%7D%7D

我该如何解决这个问题?

ng-true-valueng-false-value 都希望传递一个表达式。当你想传递一个字符串时,应该像这样传递:ng-true-value="'Y'"

来自 NG 文档的示例:https://docs.angularjs.org/api/ng/input/input%5Bcheckbox%5D

尝试更正您的单元格模板以适应此要求。

Tutorial: 201 Edit Feature

尝试使用 'boolean' 类型而不是 'checkbox'