Angular 角度4表单验证:在IE 11中设置ng dirty不起作用
我的模板HTML如下所示: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
<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;
}