Автоматический запуск средства определения состояния ошибки углового материала для IE 10/11 в угловом приложении - PullRequest
0 голосов
/ 15 января 2019

Проверка ввода формы запускается автоматически, когда приложение Angular 6 открывается в IE 11, хотя я не трогал поля ввода формы. Я обновил файл polyfills.ts для поддержки Internet Explorer, но не работал должным образом. Для всех остальных браузеров он работает нормально, только в Internet Explorer 11 он не загружает приложение Angular должным образом.

Я пытаюсь со следующим

// Custom Error State Matcher

import { FormControl, FormGroupDirective, NgForm } from 
"@angular/forms";
import { ErrorStateMatcher } from "@angular/material/core";

export class CustomErrorStateMatcher implements ErrorStateMatcher { isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean { const isSubmitted = form && form.submitted; return !!(control && control.invalid && (control.dirty || control.touched || isSubmitted)); } }

//test.component.ts

 import { Component, OnInit } from '@angular/core';
 import { FormBuilder, FormGroup, Validators } from '@angular/forms';
 import { CustomErrorStateMatcher } from '../error-control';

 @Component({
  selector: 'app-test',
  templateUrl: './test.component.html',
   styleUrls: ['./test.component.css']
  })
 export class TestComponent implements OnInit {
 exampleForm: FormGroup;
 matcher = new CustomErrorStateMatcher();
 constructor(private fb: FormBuilder) { }

 ngOnInit() {
 this.exampleForm = this.fb.group({
  firstName: ['', [Validators.required]],
  lastName: ['', [Validators.required]],
  email: ['', [Validators.required, Validators.email]]
 });
}
 examleFormSubmit() {
return false;
 }
} 

//test.component.html
div class="container">
 <form [formGroup]="exampleForm" (ngSubmit)="examleFormSubmit()">
<mat-form-field appearance="outline" [hideRequiredMarker]="true">
  <mat-label>First Name</mat-label>
  <input type="text" matInput placeholder="Enter first name" formControlName="firstName" [errorStateMatcher]="matcher">
</mat-form-field>
<mat-form-field appearance="outline" [hideRequiredMarker]="true">
  <mat-label>Email Address</mat-label>
  <input type="text" matInput placeholder="Enter last name" formControlName="lastName" [errorStateMatcher]="matcher">
</mat-form-field>
<mat-form-field appearance="outline" [hideRequiredMarker]="true">
  <mat-label>Email Address</mat-label>
  <input type="email" matInput placeholder="Enter email address" formControlName="email" [errorStateMatcher]="matcher">
</mat-form-field>

<div class="submit-form">
  <button type="submit" mat-raised-button class="submit-button"> . 
 <span>Submit</span></button>
</div>
</form>
</div>

//Updated polyfills.ts(for Internet Explorer 11 support)

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';

/** IE10 and IE11 requires the following for NgClass support on SVG 
  elements */
 import 'classlist.js';

/** IE10 and IE11 requires the following for the Reflect API. */
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';

`@angular/platform-browser/animations`
 import 'web-animations-js'; 
 import 'zone.js/dist/zone';

Есть ли способ ограничить автоматический запуск проверок ввода формы при открытии приложения Angular 6 в IE 11. Пожалуйста, предложите мне это, если у кого-нибудь есть какие-либо идеи по этому поводу.

Спасибо заранее.

...