Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

javascript - Angular2 IE11 Unable to get property 'apply' of undefined or null reference

I am getting the following error after upgrading my angular2 packages to the following versions:

  • @angular/common": "^2.3.1
  • @angular/compiler": "^2.3.1
  • @angular/core": "^2.3.1
  • @angular/forms": "^2.3.1
  • @angular/http": "^2.3.1
  • @angular/platform-browser": "^2.3.1"
  • @angular/platform-browser-dynamic": "^2.3.1
  • @angular/platform-server": "^2.3.1
  • @angular/router": "^3.3.1

Error: Unable to get property 'apply' of undefined or null reference

enter image description here

I am only getting this error in IE11, in Chrome it works fine.

I did some digging and the line that causes the error is in the angular/common module:

function combine(options) {
  return (_a = ((Object))).assign.apply(_a, [{}].concat(options));
  var _a;
}

The typescript file:

@angular/common/src/pipes/intl.ts line 175

function combine(options: Intl.DateTimeFormatOptions[]): Intl.DateTimeFormatOptions {
  return (<any>Object).assign({}, ...options);
}

The code that calls the combine function is @angular/common/src/pipes/intl.ts line 48:

'yMMMdjms': datePartGetterFactory(combine([


UPDATE

It seems that the actual error is that the .assign method is not implemented in IE11

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you are using @angular/cli and intend to support IE9-11 you can edit the src/polyfills.ts file to enable appropriate polyfills. The required polyfills are already in the file so all you need to do is un-comment them.

By default @angular/cli projects target "evergreen" browsers out of the box which means that IE isn't immediately supported, but you can add support by importing polyfills for the features you need.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...