Angular 8 using async pipe for Internet Explorer 11

℡╲_俬逩灬. 提交于 2020-07-22 18:32:05

问题


I am using *ngIf with async pipe to show and hide HTML elements. It works on Google Chrome or Firefox. But it doesn't work on Internet Explorer, how can I make it work on IE?

Here is the source code: https://stackblitz.com/edit/angular-nbxpyp


回答1:


It seems that the project you provide can work well in IE 11. It shows "Successfull Message" in all browsers. Is there any error in console when it doesn't work in IE? Have you followed the steps of supporting Angular 8 in IE 11?

You need to follow the following steps to make Angular 8 app run in IE 11:

  1. Create a new tsconfig tsconfig-es5.app.json next to tsconfig.app.json with the below contents:

    {
     "extends": "./tsconfig.app.json",
     "compilerOptions": {
         "target": "es5" 
      }
    }
    
  2. In angular.json add two new configuration section under the build and serve target to provide a new tsconfig:

    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
          ...
      },
      "configurations": {
        "production": {
            ...
        },
        "es5": {
          "tsConfig": "./tsconfig-es5.app.json"
        }
      }
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "options": {
          ...
      },
      "configurations": {
        "production": {
         ...
        },
        "es5": {
          "browserTarget": "yourAppName:build:es5"
        }
      }
    },
    
  3. Run the serve with this configuration using the below command:

    ng serve --configuration es5
    


来源:https://stackoverflow.com/questions/58380976/angular-8-using-async-pipe-for-internet-explorer-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!