我正在使用角度cli .

我真的不明白我是否可以在我的角度html模板代码中使用array.prototype.includes .

如果我尝试在我的.ts代码中使用array.prototype.includes,那么typescript编译器会抛出一条错误消息

Property 'includes' does not exist on type 'Answer[]'

从以下链接https://github.com/AngularClass/angular2-webpack-starter/issues/931看起来我必须修改tsconfig.json文件以将es7指定为lib而不是es6 . 这适用于.ts文件 .

但是,无论如何能够在我的角度2 html模板中使用array.prototype.includes并将其转换为es5等效?

<span [class.incorrect]="displayAnswer && !answer.correct && userAnswers.includes(answer)">Answer 2</span>

我知道.includes调用保持不变,因为当我在IE 11上运行应用程序时它们会抛出错误 .

Object doesn't support property or method 'includes'

或者我需要使用polyfill或其他什么?

这是我的tsconfig.json文件

{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
  "../node_modules/@types"
]
}
}

谢谢