使用Internet Explorer 11异步管道的Angular 8 [英] Angular 8 using async pipe for Internet Explorer 11
问题描述
我正在将*ngIf
与async
管道一起使用,以显示和隐藏HTML元素.它可以在Google Chrome或Firefox上运行.但是它不能在Internet Explorer上运行,如何使它在IE上运行?
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?
以下是源代码: https://stackblitz.com/edit/angular-nbxpyp
推荐答案
您提供的项目似乎可以在IE 11中正常运行.它在所有浏览器中均显示成功消息".在IE中无法正常使用时,控制台中是否有任何错误?您是否遵循在IE 11中支持Angular 8的步骤 ?
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?
您需要按照以下步骤使Angular 8应用程序在IE 11中运行:
You need to follow the following steps to make Angular 8 app run in IE 11:
-
在
tsconfig.app.json
旁边创建具有以下内容的新tsconfigtsconfig-es5.app.json
:
Create a new tsconfig
tsconfig-es5.app.json
next totsconfig.app.json
with the below contents:
{
"extends": "./tsconfig.app.json",
"compilerOptions": {
"target": "es5"
}
}
在angular.json
中的build
和serve
目标下添加两个新的配置部分,以提供新的tsconfig:
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"
}
}
},
使用以下命令在此配置下运行服务:
Run the serve with this configuration using the below command:
ng serve --configuration es5
这篇关于使用Internet Explorer 11异步管道的Angular 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!