0

My problem is that my AngularJS application has to get a record from a JSON file, but the record is named like this: something-XD. Clearly the application counts the - as an operator and I need to prevent this. Is there someway to do that?

Example:

array.push({activities:somethingAllReadyGet.something-XD})

The something-XD is the record that I have to get from the data that I have already got, if I write something like that:

array.push({activities:somethingAllReadyGet.json['something-XD']})

it doesn't work, am I doing something wrong?

Medinoc
  • 6,399
  • 17
  • 37
mautrok
  • 921
  • 1
  • 16
  • 37

1 Answers1

1

Use bracket notation for accessing properties with names that are not valid identifiers:

array.push({activities:somethingAllReadyGet['something-XD']})
Esenti
  • 697
  • 6
  • 12