在我的項目中使用的UI網,我得到的JSON對象從DB像下面選中複選框在UI格角JS
[
{
"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
我該如何解決這個問題?
很難確切地知道它是錯誤的,但你必須有某種語法錯誤在你的HTML。錯誤的線索在查詢字符串中:'p0 = {&p1 = invalid key&p2 = 2&p3 = {{grid.getCellValue(row,ol)}}&p4 = {grid.getCellValue(row,col)}}'.. 。你可能拼錯了'col',或者你可能錯過了一個大開大括號。也有助於看到控制器/ html代碼。 –