angularjs - Javascript Object attribute with '-' doesn't work properly -


this question has answer here:

i have json response in following format.

 {   "_meta" : {                "next-person-id" : "1001",                "totalpersons" : "1000"             }  } 

i using angular's $http service retrieve , trying access next-person-id attribute in javascript following,

  $http.get(url).then(         function(response){               console.log(response._meta.next-person-id);         }   ); 

but next-person-id in response undefined always. i'm able access totalpersons attribute. there problem getting attributes '-' character in javascript?

use bracket notation:

console.log(response._meta['next-person-id']); 

a possible alternative change keys use underscores, _meta.next_person_id work.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -