In my case, the webpage works fine in firefox and chrome browser but in IE v.11 it shows error as error comes in IE 11 DEVELOPER TOOLS. The error shows up in developer too
It looks like IE implements the matches
function using a non-standard name (source). That link includes a polyfill which will define the matches
function so it can be used on IE.
I was facing same issue after I updated my project from Angular 5 to 6. I found a solution with help of Derek Brown's comment. The solution is to add the following in the polyfill.ts
file:
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector;
}
For those using Angular 6 and 7 (typescript) you should modify Sanjay Gupta's answer below with:
if (!Element.prototype.matches) {
Element.prototype.matches = (<any>Element.prototype).msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}
The casting (well, untyping, really) allows the transpiler to parse the undefined method.