Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng类不使用对象和字符串_Javascript_Jquery_Css_Angularjs - Fatal编程技术网

Javascript ng类不使用对象和字符串

Javascript ng类不使用对象和字符串,javascript,jquery,css,angularjs,Javascript,Jquery,Css,Angularjs,我是新手。我用过ng-class,这里 ng-class="[{'highlighter-row-Class' : (file.id == 1 && file.processed), 'bold-row-Class' : lastSelectedResumeId == file.attributes.name, 'failed-doc': !file.processed }, getClassForHrms(file)]" css .missingfields

我是新手。我用过ng-class,这里

ng-class="[{'highlighter-row-Class' : (file.id == 1 && file.processed),
    'bold-row-Class' : lastSelectedResumeId == file.attributes.name, 
    'failed-doc': !file.processed }, getClassForHrms(file)]"
css

.missingfieldspresent {
  color: red;
}
.documentduplicate {
  color: purple;
}
.documentuploadfailed {
  color: deeppink;
}
功能

$scope.getClassForHrms = function (file) {
    if (file.attributes.hrmsMandatoryFieldsMissing) {
        return "missingfieldspresent";
    } else if (file.attributes.isDocumentDuplicated) {
        return "documentduplicate";
    } else if (!file.attributes.isDocumentDuplicated) {
        return "documentuploadfailed";
    }
};
呈现的Html

<tr ng-repeat="file in processResumeFiles" ng-class="[{'highlighter-row-Class' : (file.id == 1 &amp;&amp; file.processed), 
    'bold-row-Class' : lastSelectedResumeId == file.attributes.name, 
    'failed-doc': !file.processed }, getClassForHrms(file)]" 
    class="ng-scope [object Object] documentduplicate">

现在,这里发生的事情是,它获取对象,这样,类就不会被添加。有没有办法使用这个类


我该怎么做呢?

我认为ng类的语法有点错误(去掉方括号)

ng class=“{'highlighter-row-class':(file.id==1&&file.processed),
“粗体行类”:lastSelectedResumeId==file.attributes.name,
“失败的文档”:!file.processed},getClassForHrms(文件)”

分而治之。当您有少量代码,但问题的根源完全不清楚时,请开始一次删除一点代码,直到问题消失,然后再添加最后一部分。