Javascript 表ng上的输入验证重复

Javascript 表ng上的输入验证重复,javascript,angularjs,angularjs-ng-repeat,Javascript,Angularjs,Angularjs Ng Repeat,我正在使用angularJs应用程序制作应用程序,我有一个表,其中我在td中使用ng repeat with texbox,现在我想验证texbox,所以我使用了ng表单 和ng类,但我得到了无效的表达式错误 我的代码是 但不起作用,所以我试过这个 这也不起作用 有人能给我建议一个正确的归档方法吗 提前感谢 语法错误,应使用ng class=“{…}”notng class=:{…} 您必须引用输入名称,即ng class=“{'has-error':formName['abc-pqr-

我正在使用angularJs应用程序制作应用程序,我有一个表,其中我在td中使用ng repeat with texbox,现在我想验证texbox,所以我使用了ng表单 和ng类,但我得到了无效的表达式错误

我的代码是


但不起作用,所以我试过这个


这也不起作用

有人能给我建议一个正确的归档方法吗 提前感谢

  • 语法错误,应使用
    ng class=“{…}”
    not
    ng class=:{…}

  • 您必须引用输入名称,即
    ng class=“{'has-error':formName['abc-pqr-{{item.id}}].$dirty}”
    您实际上引用的是一个名为
    abc-pqr xx的(不存在)变量

  • 当您参考
    $dirty
    时,输入必须具有
    ng型号

正确的标记可能如下所示:

<input name="abc-pqr-{{item.id}}"
   ng-model="item.value"  
   ng-class="{'has-error':formName['abc-pqr-{{item.id}}'].$dirty}">

它只是遗漏了引号:ng class=“{'has-error':formName['abc-pqr-{{{item.id}'].$dirty}”

angular.module('myApp',[])
.controller('myCtrl',function(){
this.items=[{id:1},{id:2},{id:3}];
});
。有错误{
边框颜色:红色;
}

hey@davidkonrad thanx寻求答案,很抱歉它的打字错误,现在你能给出答案吗?