0

In Angular2 app the submit button is enabled only if several conditions are met. I use [disabled]="disabled(j)" for that.

html:

<button type="submit" class="submit" [disabled]="disabled(j)">Submit</button>

component:

disabled(j) {
   if (this.form.valid && j === this.userId) {
    return false;
   } else {
    return true;
   }     
}

It works perfectly in Chrome, but doesn't work in IE. Inspecting DOM element has shown, that instead of [disabled]="disabled(j)" it has [disabled]=""

How to fix that?

Present practice
  • 601
  • 2
  • 15
  • 27

3 Answers3

1

Most likely problem is with polyfills for form validation (which uses HTML5 and ES6 standards), and not actually the function inside an input directive. More specific, this item is the likely culprit: this.form.valid

Check out how to add polyfills, and which extra packages will be needed: https://angular.io/guide/browser-support

Note: IE is considered a deprecated browser in most applications, and full support should be avoided as a requirement (especially for versions < 10). For 10/11 the ES6 polyfills are still required.

Z. Bagley
  • 8,942
  • 1
  • 40
  • 52
0

As a work around, you can simply add the condition directly to [disabled] attribute

<button type="submit" class="submit" [disabled]="!(form.valid && j === userId)">Submit</button>
Amit Chigadani
  • 28,482
  • 13
  • 80
  • 98
0

This may have to do with polyfills, since you are using IE you may have to manually update them. See here: Angular 2 / 4 / 5 not working in IE11