AngularJS条件属性(指令)

AngularJS条件属性(指令),angularjs,attributes,Angularjs,Attributes,概念: <form-field ng-repeat="field in fields" field-model='settings[field.name]' {{field.match == undefined && '' || 'field-match="settings[field.match]"'}}> </form-field> 模板和可解析文本通常只在属性值内(当某些指令使用它们时)或在纯文本节点中,由卷曲包围 您可以通过将您的合作伙伴放

概念:

<form-field ng-repeat="field in fields" field-model='settings[field.name]'
   {{field.match == undefined && '' || 'field-match="settings[field.match]"'}}>
</form-field>

模板和可解析文本通常只在属性值内(当某些指令使用它们时)或在纯文本节点中,由卷曲包围

您可以通过将您的合作伙伴放入
字段匹配
attibute来获得所需的结果,如

<form-field ng-repeat="field in fields" field-model='settings[field.name]'
   field-match="{{field.match && settings[field.match]}}">
</form-field>

语法错误:标记“field.match”是意外的,从[field.match&&settings[field.match]}]开始的表达式[{{field.match&&settings[field.match]}]的第3列应为[:],具体取决于您使用的指令<代码>表单字段据我所知,它不是AngularJS的一部分,因此请务必阅读文档,或者如果您编写了指令,请正确管理值模板。这是我自己的指令,您是对的-它希望字段匹配是一个对象而不是字符串。。。。这就是为什么我试图将整个attr放在{{}中的原因,如果它需要一个对象,然后尝试使用
field match=“field.match&&settings[field.match]”
Attributes{$$element:JQLite[1],$attr:object,ngRepeat:“tabItem.fields中的字段”,fieldModel:“settings[field.name],…}$$element:JQLite[1]$$observators:object$attr:object-fieldMatch:“field.match&&settings[field.match]”fieldModel:“settings[field.name]”fieldName:“newpasscompare”
<form-field ng-repeat="field in fields" field-model='settings[field.name]'
   field-match="{{field.match && settings[field.match]}}">
</form-field>
attrs.$observe("fieldMatch", function(fieldMatch) {
     $scope.fieldMatch = fieldMatch;
  }
)