首页 > 解决方案 > NullInjectorError:在 IE 11 中没有用于 Angular 9 应用程序的函数 DomSharedStylesHost(_doc) 的提供程序,具有角度材料 9.1

问题描述

我正在使用带有角材料 9.1 的 anuglar 9 应用程序。我可以看到该应用程序在 Chrome、MS Edge、mozilla 中运行良好。但是对于 IE 11,我在控制台中收到以下错误。

在此处输入图像描述

其中一个组件是使用 Renderer2 将元素动态添加到 HTML 页面。我不知道这个错误的修复方法是什么。

标签: angularangular-materialinternet-explorer-11

解决方案


我正在使用带有 Angular + Angular 材料的 .net 作为前端。我们在 IE11 中遇到了上述问题。我正在添加特定的 polyfill。此外,错误消息正在重定向其他解决方案。最后我决定包含所有的 polyfill。感谢博日诺夫斯基。

这是我在 bundleconfig.cs 中添加的代码。

 bundles.Add(new Bundle("~/bundles/angular")
    .IncludeDirectory("~/dist/libs/", "*.js", true)
          .Include("~/dist/libs/runtime*",
                "~/dist/libs/polyfills*",
                "~/dist/libs/vendor*",
                "~/dist/libs/main*"));

推荐阅读