简体   繁体   中英

How can I escape @ symbol while fetching json in angular.js?

I'm trying to fetch some data from a json using angular. This is the json structure:

{
   "@rid":"#12:0",
   "@version":2,
   "@class":"Node",
   "name":"1",
   "childs":[
      {
         "@rid":"#11:2",
         "@version":1,
         "@class":"Link",
         "name":"1.4.5 --> 1.5.2.2.1",
         "parent":"#12:0",
         "from":"#12:61",
         "to":"#12:24"
      },
      {
         "@rid":"#11:3",
         "@version":0,
         "@class":"Link",
         "name":"1.5.2 --> 1.2.4",
         "parent":"#12:0",
         "from":"#12:17",
         "to":"#12:137"
      },

and so on.. Here I'm fetching data:

$http.get('nodes/nodes.json').success(function(data){
$scope.nodes = data;
});

And then I try to print:

<li class="node-children" ng-repeat="node in $parent.node.childs">
    <a ng-href="#" ng-click="">{{node.['@rid']}}</a>
</li>

But it doesn't work. I also tryied {{node.["@rid"]}} but it's still not working. How can I escape @ symbol while fetching json?

Thanks

Either you use the dot notation to access a field, or you use the array notation. But not both. It should be

{{ node['@rid'] }}

or

{{ node["@rid"] }}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM