.directive('aaValMsgFor', ['aaFormExtensions', 'aaUtils', function (aaFormExtensions, aaUtils) {
//generate the validation message for a particular form field here
return {
require: ['^form'],
priority: 1,
scope: true,
link: function ($scope, element, attrs) {
var fullFieldPath = attrs.aaValMsgFor;
var fieldInForm, formObj;
var innerScope = $scope;
while ((!fieldInForm || !formObj) && innerScope) {
fieldInForm = innerScope.$eval(fullFieldPath);
formObj = innerScope.$eval(fullFieldPath.substring(0, fullFieldPath.indexOf('.')));
if ((!fieldInForm || !formObj)) {
innerScope = innerScope.$parent;
}
}
innerScope.$eval(fullFieldPath);
我总是回复未定义。
如何检查范围内是否存在我的fullFieldPath
model.name?我可以检查范围内的所有表达式,以便我知道我是否以正确的方式?
编辑:
我之前也做过:
$compile(element)(scope);
和元素的名称为:model.name
但稍后在innerScope上。$ eval不起作用......
答案 0 :(得分:2)
如果您为指令提供控制器参数(它被注入为链接的第四个arg),您可以更改链接函数以包含模型:
155 Query SET SESSION sql_mode =
REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
@@sql_mode,
"STRICT_ALL_TABLES,", ""),
",STRICT_ALL_TABLES", ""),
"STRICT_ALL_TABLES", ""),
"STRICT_TRANS_TABLES,", ""),
",STRICT_TRANS_TABLES", ""),
"STRICT_TRANS_TABLES", "")
155 Query SET NAMES utf8
155 Quit