Issues with Angular 9 application compatibility with IE11

Our Angular 9 project runs smoothly on Google Chrome and Firefox, but nothing appears on IE11. Despite trying various solutions found online and following related blogs, the issue remains unresolved.

Here is a snippet from my tsconfig.json:

{  
    // Compiler options here
}

Additionally, I have another configuration file for ES5 compatibility:

{   
    // Compiler options for ES5 target
}

Furthermore, here are the dependencies listed in package.json for reference.

{ 
    // List of dependencies
}

I also referred to this resource here without success. Oddly, there are no errors shown in the Console window of IE11 as seen in the screenshots provided.

Check out these screenshots: https://i.sstatic.net/sr97g.png, https://i.sstatic.net/SLtlc.png.

Look at this polyfills.ts file that contains crucial imports for Angular setup.

  
    // Polyfills needed for Angular application
}

---------------EDIT------------------

https://i.sstatic.net/j9mRQ.png

https://i.sstatic.net/w4CGU.png

https://i.sstatic.net/ZQCel.png

https://i.sstatic.net/pf2P9.png

Answer №1

Have you made adjustments to the browserslist file? It is recommended to remove the not before IE 9-11. The browserslist configuration should look like this:

> 0.5%
last 2 versions
Firefox ESR
not dead
IE 9-11 # For IE 9-11 support, make sure 'not' is removed.

In my case, I created a new Angular 9 application and tested it successfully in IE 11. I included a new tsconfig-es5.app.json file, updated the configurations in angular.json, edited the browserslist file, and executed ng serve --configuration es5. You can view the result here. Additionally, no uncommenting was necessary in the polyfills.ts file.

This is how my tsconfig.json file looks:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

And here's a snippet from my package.json file:

{
  "name": "angular9",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.1.0",
    "@angular/common": "~9.1.0",
    "@angular/compiler": "~9.1.0",
    ...
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.0",
    "@angular/cli": "~9.1.0",
    ...
  }
}

Answer №2

To get it to function properly on both Angular 8 and 9 versions, you need to make the following adjustments:

  • Update browserslist file to change from not IE 9-11 to IE 9-11

  • Modify tsconfig.json file by changing

    "target": "es2015"
    to
    "target": "es5"

In most cases, these changes should be sufficient. If you encounter any errors, particularly related to complex UI/UX, consider adjusting the polyfills.ts file as well.

  • Uncomment // import 'classlist.js'; and // import 'web-animations-js';
  • Remember to run
    npm install --save classlist.js web-animations-js

Answer №3

Kindly eliminate the following line from your polyfills.js file.

**/***************************************************************************************************
 * Add `$localize` to the global scope - required for i18n tags in Angular templates.
 */
import '@angular/localize/init';**

This adjustment will ensure compatibility with IE11 browser. Upon reviewing some documentation, it has been noted that localize may not be supported in es5.

Answer №4

If the problem persists, follow these steps:

  1. Uncomment IE11 in browserlists.ts
  2. In tsconfig.ts, change the target to "es5" and add "es5" to the lib: "target": "es5", "lib": [ "es2018", "es5", "dom" ]

After making these changes, run ng build again before starting ng serve.

Answer №5

To solve compatibility issues with older versions of Internet Explorer (IE), locate the commented out import statements in your polyfills.ts file under the section

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

// import 'classlist.js';  // Run `npm install --save classlist.js`.

Make sure to uncomment the above import statement to enable your app to work properly on those specific IE browsers. Don't forget to execute the command below as well:

npm install --save classlist.js

You may also need to uncomment the following import:

// import 'web-animations-js';  // Run `npm install --save web-animations-js`.

Remember to run the command below after uncommenting it:

npm install --save web-animations-js

If the steps above do not resolve the issue, you can try the following troubleshooting tips:

In the browserslist file, consider replacing not IE 9-11 with IE 9-11.

Additionally, in the tsconfig.json file, look for

"target": "es2015"
(or similar) and change it to
"target": "es5"
.

Answer №6

1. To enable ES5 browser support, add the following property in your project's angular.json file within the projects > architect > build section:

"es5BrowserSupport": true

2. Update your target from

"target": "es2015"
to
"target": "es5"
in your tsconfig.json file.

Answer №7

To implement the following code in your project, locate the index.html file within the head tag (projectName/src/index.html) and then restart your application by running ng serve.

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Uncaught Error: Unable to access 'visit' property of null

Sharing this in case it helps someone else who encounters the same error, as the stack trace doesn't offer any clues on what might have caused the problem. ...

Error in Angular compiler.js at line 2531: Multiple components found for this element, causing template parse errors

After browsing through various topics with a similar issue, I have not found any solutions that address my specific reasons. The problem lies with a standard primeng button component. <div [hidden]="isHidden||isProgramVisible" id="st ...

The status of the Office.js appointment remains updated even after the saveAsync callback is executed

Utilizing the Office JavaScript API for an Outlook add-in, I encountered a issue with some code designed to save an appointment and close its window. Despite saving the appointment through the API, I continue to receive a "Discard changes" confirmation dia ...

The Select element in angular fails to choose the intended option when tested with Cypress

I am encountering a challenge in my automation testing project where I need to select an option from a select element. The project is built using Angular and I am using Cypress for automation testing. As a newcomer to Cypress, I followed the instructions ...

Enhance Your SVG Elements with Angular Tooltips

I am faced with a challenge on my website where I have an SVG element: <ellipse id="svg_2" cy="78.999999" cx="1042.499999" stroke-width="1.5" stroke="#000" fill="#fff"/> My goal is to add a tooltip to this specific element. I attempted using NGPrim ...

Issue with dynamic imports and lazy-loading module loadChildren in Jhipster on Angular 8, not functioning as expected

When utilizing dynamic import, it is necessary to modify the tsconfig.json file in order to specify the target module as esnext. ./src/main/webapp/app/app-routing.module.ts 14:40 Module parse failed: Unexpected token (14:40) File was processed with these ...

Can data from an Angular app be accessed by an external JavaScript code within the same project?

I've been thinking about a theoretical scenario that luckily I haven't encountered yet. Imagine I have an Angular Project compiled in My PROJECT FOLDER. <br/> Inside this PROJECT FOLDER, there's another JAVASCRIPT FILE external to ...

Scrolling horizontally in Ionic framework

In regards to the response found on Ionic - Horizontal scroll tab for Categories, I have a question. I am curious about what needs to be included in the category.model. Can anyone provide some guidance? ...

Establish a default value for cascading Angular dropdowns

In my JSON data, each country has an ID associated with it. I am trying to set the default value of a select option to 'selected' based on a specific ID (in this case, 100). Here is the code for my select element: <select (change)="onNational ...

Establish a connection using Angular 4 HTTP POST to communicate with a Java REST API, as it is not permitted on the server

I am facing an issue with my Angular 4 client service that is calling a REST method declared on a Java server using a PostMapping annotation. When I make the call from Angular, it is not accepted by the server. However, when testing it on Postman, it work ...

Tips for effectively utilizing the Ngrx navigation function

While exploring NgRx, I stumbled upon navigation. According to the documentation, it seems like this effect should trigger when the component loads. However, I'm facing an issue where this effect is not getting triggered. Other effects that I've ...

Anticipate the absence of a specific object length

I have an Object that I need to test for null: getLastTeamUpdatedItemLogBuffer(): IBufferElement { const storageItems = this.storageSvc.getItem(StorageKey.lastTeamUpdatedItem, true) as IBufferElement; return storageItems || null; } This is the IBufferE ...

Angular does not recognize the boolean variable

Within my Angular component, I have declared two boolean variables: editingPercent: boolean = true; editingCap: boolean = false; In the corresponding HTML file, there is a checkbox that updates these variables based on user input: checkedChanged(e) { ...

Ways to resolve the issue of npm being unable to globally install typescript

While trying to globally install TypeScript using npm sudo npm install -g typescript An error occurs during the installation process with the following message: ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/typescript/bin/ ...

Angular 2 decorators grant access to private class members

Take a look at this piece of code: export class Character { constructor(private id: number, private name: string) {} } @Component({ selector: 'my-app', template: '<h1>{{title}}</h1><h2>{{character.name}} detai ...

The TypeScript error message reads: "You cannot assign type 'undefined' to type 'ReactElement'."

I'm encountering an error in my react project TypeScript error Argument of type 'ReactNode' is not compatible with parameter of type 'ReactElement<any, string | JSXElementConstructor<any>> | ReactElement<any, string | JSX ...

What is the best way to link multiple select tags in an HTML document?

I am working with a data grid that contains student information such as Name, Class, and Score. Each row has a checkbox for selection. The requirement is that when the user selects one or more rows and clicks on the "show information" Button, a new windo ...

collaborating on data within closely related components in a table display

I am trying to figure out the best way to pass data among sibling components. For example, let's say I have a data entry grid structured like this: <tr *ngFor="let item of frm.controls.items.controls; let i=index" [formGroupName]="i"> <td ...

Converting Blob to File in Electron: A step-by-step guide

Is there a way to convert a Blob into a File object in ElectronJS? I attempted the following: return new File([blob], fileName, {lastModified: new Date().getTime(), type: blob.type}); However, it appears that ElectronJs handles the File object differently ...

Once the submit button is clicked in Angular Dev Extreme, validation processes are triggered once more

Currently experiencing an issue on a page with textboxes and validations. After entering values into the textboxes and clicking submit, the values successfully pass to the database, but the validations continue to appear again upon submitting. This problem ...