1

I have an Angular 6.x app running perfectly in Chrome. The problem is when trying to run it in IE 11, I'm getting the error:

Error: Invalid argument. at DefaultDomRenderer2.prototype.setProperty...

enter image description here

Already tried all answers in StackOverflow that I could find with no help. I'm listing theme here so you guys won't try them as answers:

  • Added all polyfills needed for IE but still having the same problem.
  • Added in head tag:

    <meta http-equiv="X-UA-Compatible" content="IE=11">
    

Thank you for helping.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
benshabatnoam
  • 7,161
  • 1
  • 31
  • 52
  • 2
    Don't support IE11 is my advice. Seriously. If you really have to - I'd recommend updating your project to the latest version of Angular using `ng update`. I seem to recall they fixed an issue with some polyfills recently. – hevans900 Dec 04 '18 at 13:49
  • Can you post the Enough code to reproduce the problem as in [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). I have created a new angular6 sample and add the header tag, it seems that everything works well on my side. – Zhi Lv Dec 05 '18 at 08:00
  • @ZhiLv-MSFT I'll try to do that – benshabatnoam Dec 05 '18 at 08:20

2 Answers2

5

I've found the problem and fixed it. I'm writing this answer to save time for others facing this problem.

The problem is binding an incorrect valued variable to an HTML attribute (any HTML attribute).

e.g.

Assigning a variable to a dir attribute in a p tag, must be defined with one of the possible values for dir attribute, which are: ltr | rtl | auto

Having this line in html: <p [dir]="myDir">Test</p>

When myDir = undefined or myDir = 'bla bla bla' or any other incorrect value - we'll get an error.

When myDir = 'rtl' or any other correct value - we won't get an error.

Added a DEMO to run in IE for seeing this error reproduced.

For conclusion I think we can say that when binding to an HTML attribute we'll have to be very careful to have a valid attribute's value, this way we won't face this problem.

benshabatnoam
  • 7,161
  • 1
  • 31
  • 52
  • Got the exact same message using `` instead of `` (in case someone else than me comes here after googling for this exact error message). No error messages with other browsers. – Wis Feb 14 '19 at 09:05
  • 2
    Same, but with ` – John Neuhaus Aug 14 '19 at 23:16
1

I also had this error when using:

const input = {
   time: 'time',
   date: 'date'
}

<input [type]="input.date"/>
<input [type]="input.time"/>

IE 11 inputs don't support types of date and time. So any element that IE doesn't support will likely throw the same error.

dale
  • 1,258
  • 2
  • 17
  • 36