你可能想看看这个答案
https://stackoverflow.com/a/28127498/1585304
当您使用 ui-grid 时,您实际上是在一个孤立的范围内工作。
这意味着您不能仅通过在 html 中键入 var 的名称来访问父范围。
为了访问您的 customMsg 变量,您需要使用grid.appScope引用父范围。
您的列定义应该更像这样。
{
field: 'company',
displayName: 'Company',
enableColumnMenu: false,
editableCellTemplate: "<div><form name=\"inputForm\">
<input type=\"INPUT_TYPE\" ng-class=\"'colt' + col.uid\"
ui-grid-editor ng-model=\"MODEL_COL_FIELD\" minlength=3
maxlength=10 required><a href=\'#\' data-toggle=\'tooltip\'
data-placement=\'top\' title=\'error!\'
ng-show=\'!inputForm.$valid\'>errMsg - {{grid.appScope.customMsg}}
</a></form></div>"
}
唯一的问题是很难看到消息,因为表单几乎完全被行隐藏了。
希望这可以帮助。