1

I'm working with a 3rd party API to populate my front end. I have no control over the API and just displaying data using REST URLs.

<tr ng-repeat="stat in allStats">
      <td>{{stat.date}}</td>
      <td>{{stat.Organic Inbound}}</td>
</tr>

Please check this {{stat.Organic Inbound}}. We can't use this Organic Inbound because there is a space between those 2 words. And I can't change the backend variable format. Please tell me how to use these kind of variables in AngularJS ng-repeat. I used it once and honestly I don't remember how I did it. I tried <td>{{stat.$(Organic Search)}}</td> and <td>{{stat.'Organic Search')}}</td> and many more ways.

We can't map this object in the JavaScript controller and change it because there are thousands of data coming and it will make the process slow. Please tell me how to solve this. Can't we use \ to ignore this space? Any suggestion is welcome.

1 Answer 1

4

You need to access that using square brackets like:

<td>{{stat['Organic Inbound']}}</td>

This is because Organic Inbound is the key of the object stat and it is separated by space. Using square brackets will evaluate the whole string value Organic Inbound as a key of stat.

Sign up to request clarification or add additional context in comments.

1 Comment

@ChanakaDeSilva glad to help

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.