Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.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
Angular6 ngClass:使用&&;运算符分析器错误:缺少预期值:在列X处,_Angular6 - Fatal编程技术网

Angular6 ngClass:使用&&;运算符分析器错误:缺少预期值:在列X处,

Angular6 ngClass:使用&&;运算符分析器错误:缺少预期值:在列X处,,angular6,Angular6,我试图在ngClass的条件下使用&&: 我的代码块是: <div class="col-sm-12 col-md-6 form-group " [ngClass]="{has-error : (!CountryName.valid && CountryName.touched)}"> <label class="control-label">Country Name</label>

我试图在ngClass的条件下使用
&&

我的代码块是:

<div class="col-sm-12 col-md-6 form-group " [ngClass]="{has-error : (!CountryName.valid && CountryName.touched)}">
                        <label class="control-label">Country Name</label>
                        <input type="text" class="form-control" name="CountryName" placeholder="Country name" maxlength="50" minlength="5" required 
                               ngModel #CountryName="ngModel" />

                    </div>

国名
&我得到这个错误:

语法分析器错误:[{has ERROR]中的第5列缺少预期值 :(!CountryName.valid&&CountryName.toucted)}]in C:/Abdul/TestProjects/Angular6CRUDAPI/Angular6CRUDAPI/src/app/masters/country-master/country-add-2/country-add-2.component。html@23:64 (”


我知道我犯了一些愚蠢的错误,我找不到。

好的。明白了:
有错误
应该在引号中

作为


好的。明白了:
有错误
应该用引号括起来

作为

如果在类名中使用破折号,则必须在ngClass中使用单引号,或者重命名不带破折号的类名 像

[ngClass]=“{'has-error':(!CountryName.valid&&CountryName.toucted)}

[ngClass]=“{haserror:(!CountryName.valid&&CountryName.toucted)}

如果在类名中使用破折号,则必须在ngClass中使用单引号,或者重命名类名而不使用破折号” 像

[ngClass]=“{'has-error':(!CountryName.valid&&CountryName.toucted)}

[ngClass]=“{haserror:(!CountryName.valid&&CountryName.toucted)}

 [ngClass]="{'has-error' : (!CountryName.valid && CountryName.touched)}"