4

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>
0

1 Answer 1

5

Use Bracket notation like this

 <td>{{fdata['@defURI']}}</td>

Working Codepen

Sign up to request clarification or add additional context in comments.

3 Comments

Is there way to use it in ng-bind directive?
Yes try it as <div ng-bind="fdata['@defURI']"></div>
Hehe, thanks. That's great. I just forgot to delete dot when I tried with dot notation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.