I am getting the following error after upgrading my angular2 packages to the following versions:
Error: Unable to get property 'apply' of undefined or null reference
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
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.
Angular has dependency on core-js. Thereby you can use Object.assign polyfills from it:
import "core-js/client/shim"; // or load it before other angular2 & zone.js stuff
import "zone.js";
import "reflect-metadata";
It's really annoying that the Angular Materials tutorial doesn't mention this problem. Anyone using IE11 and following their tutorial will hit this issue.
The solution, as others have mentioned, is to simply uncomment those lines in your project's polyfills.ts
file.
But really, this should've been mentioned in their tutorial.
I'm spending far too many hours Googling to find solutions to these Angular problems...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With