我是新来AngularJS,而我面对了以下问题。结果我无法一个JSON关键的出发与 @
符号绑定。
例如:
VAR的sampleData ={ 的DataModel:{ 字段: { 格式化:空, DisplayOrder:0, @defURI:reporting.dashboard.TDataSetField, 显示名称:名字, DefURI:字符串, 名:名字, @nodeKey:346316115241271300 } ] }}
和我的code是:
< TR NG重复=FDATA在fieldData.DataModel.Fields> &所述; TD> {{fdata.Name}}&下; / TD> < TD> {{FDATA @ defURI}}< / TD> <! - 这行抛出AngularJs错误 - > < / TR>
解决方案
使用括号标记像这样
< TD> {{FDATA ['@ defURI]}}< / TD>
工作codePEN
I am new to AngularJS, and I am facing the following issue.
I am unable to bind a JSON key starting with @
symbol.
Example:
var sampledata =
{
"DataModel": {
"Fields": [
{
"Format": null,
"DisplayOrder": 0,
"@defURI": "reporting.dashboard.TDataSetField",
"DisplayName": "Firstname",
"DefURI": "String",
"Name": "firstname",
"@nodeKey": 346316115241271300
}
]
}
}
and my code is:
<tr ng-repeat="fdata in fieldData.DataModel.Fields">
<td>{{fdata.Name}}</td>
<td>{{fdata.@defURI}}</td> <!-- this line is throwing an AngularJs error -->
</tr>
解决方案
Use Bracket notation like this
<td>{{fdata['@defURI']}}</td>
Working Codepen