THis is the format of my JSON data:
[
{
"Department_id": "34",
"Names": [
"Jack Jones",
"Matt Jones",
"Lynn Lewis"
],
"Employee-num": 3,
"Salary-info": {
"Jack Jones": 1000,
"Matt Jones": 2920,
"Lynn Lewis": 1500
},
},
]
How do you get the "salary-info"? And to display like the following:
Jack Jones: 1000
Matt Jones: 2920
Lynn Lewis: 1500
On jade, I try to access it using
p(ng-repeat='details in info.salary-info') {{ details }}
But it's not working and it only display a "0" on the screen.
info.Department_id works for displaying the department id of 34.
Problem solved.
The problem why nothing displayed is because of the hyphen exists on object names.
You need to access this kind of objects with a ' [" name of the object with a hyphen"] ',
like: {{ info["salary-info"] }}
instead of {{ info.salary-info }}.
Hopes it helps anyone having the same issue.
people:[{name:'Jack',salary:100]}
. Arrays can be sorted but objects can't. Also generally best not to use special characters in property names when it can be avoided