当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Angular JS curly braces stop evaluation at dash in object property name

问题描述:

This question already has an answer here:

  • Are dashes allowed in javascript variable names?

    4 answers

网友答案:

Use bracket notation

<p> {{archivi['FASE-XD']}}</p>
网友答案:

The problem is that the js parser interprets dash - as a subtract operator.

so just change

<p> {{archivi.FASE-XD}}</p>

to

<p> {{archivi['FASE-XD']}}</p>
网友答案:

The '-' is an operator, and will treat it that way. So to access the property, you will need to do {{archivi['FASE-XD']}}

分享给朋友:
您可能感兴趣的文章:
随机阅读: