IE9 TypeError 'apply'
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.0.1 node: 7.9.0 os: win32 x64 @angular/animations: 4.1.0 @angular/common: 4.1.0 @angular/compiler: 4.1.0 @angular/core: 4.1.0 @angular/forms: 4.1.0 @angular/http: 4.1.0 @angular/platform-browser: 4.1.0 @angular/platform-browser-dynamic: 4.1.0 @angular/router: 4.1.0 @angular/cli: 1.0.1 @angular/compiler-cli: 4.1.0
Repro steps.
ng build --aot --prod tested on a real webserver
The log given by the failure.
In console of ie9 : TypeError: Object doesn't support property or method 'apply'
Desired functionality.
Works on ie9
Mention any other details that might be useful.
I tested with polyfills.ts ( core-js/es6 + classlist ). Also tested with shim.min.js, Typed Array, Blob, FormData from https://angular.io/docs/ts/latest/guide/browser-support.html
You have to omit web-animations-js from IE9 completely @blackrek
@steveblue any chance you can post your polyfills.ts? I also have the same issue. I've updated to 5.2.3, omitted web-animations-js, set the zone.js version to 0.8.4, have set the routing to {useHash:true}, added console-polyfill, yet I'm still seeing the error "object doesnt support property or method apply" on IE9
Are you also injecting BrowserAnimationsModule @bog3yman? Here is an issue for that https://github.com/angular/angular/issues/21083
I was initially injecting BrowserAnimationsModule, but I've commented out/removed all references to that and component animation after seeing your issue.
Unfortunately I'm still getting the same error though even after that.
You are probably missing a polyfill then. The necessary polyfill are listed in ^ issue @bog3yman
I also have the same problem, The following code works fine for IE11, but IE9 raise Access is denied and SCRIPT438: Object doesn't support property or method 'apply' addCase() { let headers = new HttpHeaders();
headers.append('Content-Type', 'application/json');
headers.append('cache-control', 'no-cache');
headers.append('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
headers.append('Access-Control-Allow-Origin', '*');
this.http.post(this.url,this.tempJSON,{headers: headers})
.subscribe(
(val) => {
console.log("POST call successful value returned in body", val);
},
response => {
console.log("POST call in error", response);
},
() => {
console.log("The POST observable is now completed.");
});
}
I've verified Angular 6.0.0 works in IE9 with the exception of Animations (which doesn't have a polyfill for IE9). If you are still facing an issue, its probably a polyfill that is missing for your particular use case.
I found a good formula for diagnosing IE9 issues. TraceKit will print stack traces in IE9.
You need TraceKit to be injected in the
or bundled appropriately with Webpack as a dependency. <script src="/node_modules/tracekit/tracekit.js"></script>
You can hook into the Angular ErrorHandler in your app.module.ts:
declare let TraceKit: any;
TraceKit.report.subscribe(function yourLogger(errorReport) {
console.log(errorReport.message);
errorReport.stack.forEach(function (err) {
if (err.func) {
console.log(err.func);
}
if (err.context) {
console.log(err.context.join())
}
console.log('ERROR ' + err.url + ' [' + err.line + ']');
})
//console.dir(JSON.stringify(errorReport, null, 4));
//send via ajax to server, or use console.error in development
//to get you started see: https://gist.github.com/4491219
});
@Injectable()
export class CustomErrorHandler implements ErrorHandler {
constructor() { }
handleError(error) {
// your custom error handling logic
if (navigator.userAgent.indexOf("MSIE 9.0;") === -1) {
console.error(error);
} else {
TraceKit.report(error);
}
}
}
Then inject this new Class as a provider:
providers: [{
provide: ErrorHandler,
useClass: CustomErrorHandler
}
Using TraceKit I was able to easily find the problem behind Object doesn't support property or method 'apply' and then patch IE9 with the appropriate polyfill.
Hey Guys,
Just fixed this stuff for myself and want to update you with my experience as it can be very helpful..
To make Angular 6.0.0 run for IE9:
- In /src/polyfills.ts you should uncomment (and install):
import 'core-js/es6/reflect'; import 'web-animations-js'; // Runnpm install --save web-animations-js.Note uncommenting// import 'web-animations-js';caused for me strange errors, but it is unneeded if you are not using angular animations - Set useHash to true for your route:
imports: [RouterModule.forRoot(routes, {useHash: true})], - Also due to console is undefined in IE9 by default (application was broken untill you opened dev tools to enable console) and thanks too @idasbiste comment here:
Install https://github.com/paulmillr/console-polyfill and import
import 'console-polyfill';to polyfills.ts
@hudzenko that's a fantastic description, thanks for sharing! Closing the issue here. In case the steps that @hudzenko shared do not work for you please open a new issue.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.