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,577
  • 20
  • 42
mautrok
  • 961
  • 1
  • 17
  • 41

1 Answers1

1

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

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