简体   繁体   English

Angular 8:检查数组包含组件视图中的字符串值在 IE 中不起作用

[英]Angular 8 : Check array contains value of string in component view not work in IE

I have angular 8 application.我有 angular 8 应用程序。 I want to check if array contains the given string in component view.我想检查数组是否包含组件视图中的给定字符串。 I have used Array.includes which work in chrome but IE gives error Object doesn't support property or method 'includes'我使用Array.includes ,它在 chrome 中工作,但 IE 给出错误Object 不支持属性或方法“包含”

Component view Look like:组件视图看起来像:

<div [ngClass]="{'is-invalid': invalidProps?.includes('errorprop')}"> 
  Error message 
</div>

Try to add line below in the polyfills.ts file.尝试在polyfills.ts文件中添加以下行。

import 'core-js/es6/array';

It may help you to fix your error.它可以帮助您解决错误。

I added below line to polyfills.ts file and it working我在 polyfills.ts 文件中添加了下面的行并且它工作

import "core-js/es/array";

Thanks for hint.谢谢提示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM