Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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
Angular 角度4表单验证:在IE 11中设置ng dirty不起作用_Angular - Fatal编程技术网

Angular 角度4表单验证:在IE 11中设置ng dirty不起作用

Angular 角度4表单验证:在IE 11中设置ng dirty不起作用,angular,Angular,我的模板HTML如下所示: <input formControlName="schduleName" type="text" id="name" [style.width.%]="89.5" [class.ng-dirty]="!newSchdule.controls.schduleName.untouched || newSchdule.controls.schduleName.valid"/> this.ne

我的模板HTML如下所示:

<input formControlName="schduleName" 
        type="text"
        id="name"
        [style.width.%]="89.5"
         [class.ng-dirty]="!newSchdule.controls.schduleName.untouched || 
newSchdule.controls.schduleName.valid"/>
this.newSchdule = this.formBuilder.group({
        schduleName: ['', Validators.required],
        scheduleId: [this.defaultId, Validators.required],
        scheduleCreator: [this.defaultCreator, Validators.required],
        scheduleCreateTime: [this.defaultCreateTime, Validators.required]
    });

“[class.ng dirty]”在chrome中可用,但在IE 11中不可用。如何修复它?有人能帮我吗?我很困惑。

我的印象是,通过尝试在代码中设置
ng dirty
,您正在与尝试设置的Angular竞争。如果您想要条件的一些自定义格式
!未触及且有效的
,您可以应用自己的类名(例如,
我的脏的
):

CSS文件可以包含
ng dirty
my dirty
的样式属性:

<input 
    id="name" 
    type="text" 
    formControlName="username" 
    class="form-control" 
    [class.my-dirty]="isDirty" />
input.my-dirty {
  background-color: lime;
}

input:not(.my-dirty) {
  background-color: orange;
}

input.ng-dirty {
  border: solid 4px red;
}

用于在IE11和其他浏览器中测试代码。您可以看到,
ng dirty
由Angular管理,而
my dirty
则根据我们的条件应用
!未触及和有效

您是否检查了我应该导入哪些Polyfills.ts来解决此问题?类列表是否正确?我已检查,但它不起作用。类绑定本身应该在IE11中起作用。看见问题可能与
ng dirty
有关,或者与
未触及的
有效的
标志有关。
input.my-dirty {
  background-color: lime;
}

input:not(.my-dirty) {
  background-color: orange;
}

input.ng-dirty {
  border: solid 4px red;
}