3

I am hitting an API which retrieves a nested JSON and setting it to my $scope.data variable.

I do an ng-repeat like ng-repeat="event in data". and try to access a value in the JSON {{[email protected]}}

There is an error Lexer Error: Unexpected next character at columns 14-14 [@] in expression [[email protected]].

When I forcefully remove the @ from the JSON returned from the API and access as {{event.src.userID.title}} it works properly.

Please help so that I can access value with the @ in the key name.

The API that I hit returns a list [{"":""},{},{},{}] {"":""} is a nested list

3
  • is the key wrapped in double quotes? Commented Oct 26, 2015 at 22:12
  • yes, it is wrapped in double quotes Commented Oct 26, 2015 at 22:16
  • Possible duplicate of How I can Bind JSON key Starting with @symbol Using Angular JS - according to this answer, you need to use the bracket notation Commented Oct 26, 2015 at 22:22

1 Answer 1

4

You have to use a different syntax to access an object property whose name isn't a valid variable name:

{{event.src["@userID"].title}}

enter image description here

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

1 Comment

Worked like charm! Thanks!

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.