6

enter image description here

Above is a picture of the JSON data being returned by the API. As you can see some of the JSON keys have two words with a space in between them. How can I access that in my angular app. This is coming in as an array BTW.

I have tried:

<li ng-repeat="task in mainTask.Tasks"> {{ task.['CAR ID'] }} </li>

with no luck. Thanks for any help.

2
  • 1
    How about task['CAR ID']? No period between task and the opening bracket. Commented Jul 25, 2016 at 20:11
  • @andrunix I'm an idiot. I cant believe i didn't try that. Cause ya it worked. Answer my question with that answer and I will select it as correct! Commented Jul 25, 2016 at 20:13

2 Answers 2

11

You don't need the dot to access the value. Try:

{{ task['CAR ID'] }}
Sign up to request clarification or add additional context in comments.

3 Comments

@andrunix answered this first but didn't post it as an answer so to be fair I am selecting his as the correct answer. But both of you are nailed it! So I did up-vote yours also. :)
I've done the same, just looked and there's seconds between the answers.
I'll upvote Daniel's answer too. Even though I need the rep points more than him :)
6

How about

task['CAR ID']

No period needed between task and the opening bracket.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.