Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular JS not parsing nested JSON key with the at (@) in the key name

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

like image 829
George Avatar asked Jan 21 '26 15:01

George


1 Answers

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

like image 182
dave Avatar answered Jan 24 '26 06:01

dave