Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 - script5007: Unable to get property 'apply' of undefined or null reference

I created a simple project:

ng new my-app
cd my-app
ng serve

Chrome and Firefox it's OK, but when I execute in IE 11, it returns this error: SCRIPT5007

enter image description here enter image description here

Can someone help me?

like image 593
Renan Wagner Bendlin Avatar asked Feb 16 '17 12:02

Renan Wagner Bendlin


2 Answers

It is the issu of CLI not the angular

In newer version of ANGULAR - CLI, src\polyfills.ts are commented out by default.

  1. open file src/polyfills.ts
  2. un-comment these files and done

BROWSER POLYFILLS

/** IE9, IE10 and IE11 requires all of the following polyfills. **/

Here is the list of files:

 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/set';
like image 76
Ali Adravi Avatar answered Nov 13 '22 06:11

Ali Adravi


I found this issue can be reproduced in Angular 2.4 and you can fix this by using Angular 2.2.x or 2.3.x. I have filed an issue for the Angular team, here is the link: https://github.com/angular/angular/issues/14592

=================================================

It seems it is not an issue of angular, but angular cli. Please refer to https://github.com/angular/angular-cli/issues/4862

As the answer of the angular-cli issue said, the IE11 polyfills are commented out by default, you need to enable the polyfills in src\polyfills.ts.

like image 4
zhxx Avatar answered Nov 13 '22 06:11

zhxx