question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support rendering of JSON arrays

See original GitHub issue

It would be great if one can render such arrays (key need for my application case):

'content': [
    "Das ist ein langer Satz",
    "Das ist ein zweiter langer Satz",
],
'people' : [
  {
    'name': "John(DE)"
  },
  {
    'name': "Tim(DE)"
  }
]

with an expression like:

<span translate="content[0]"></span>
<span translate="people[0].name"></span>

See (not working) example: http://plnkr.co/edit/u2Z3l2?p=preview

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:24 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
Swissbitecommented, Feb 4, 2015

It would also be great if I could get the array.

'content': [
    "Das ist ein langer Satz",
    "Das ist ein zweiter langer Satz",
],

and in the controller:

app.controller($translate, $scope) {
$translate('content').then(function(contentArray) {
  $scope.content = contentArray;
}))
}

and the corresponding view

<ul>
<li ng-repeat='item in content'>item</li>
</ul>
2reactions
stryjucommented, Feb 9, 2015

@nikolayhg

the keys are being “flattened”, so just change your notation to “invalid” path, like so: http://plnkr.co/edit/K3pbBD7hJcjHJrjo1X4C?p=preview


tl;dr

use array.index.property, not array[index]property, like people.0.name


i’d love, however, to get the full array, as in @Swissbite example - currently struggling with that…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to render array of JSON data in React Redux
Merge all object, into one by spreading the array into Object#assign · Add the length property · Convert back to an array using...
Read more >
Dynamically Rendering JSON Objects in Arrays in React JS ...
Dynamically Rendering JSON Objects in Arrays in React JS Components Iterating Over an Array with J · Key moments. View all · Key...
Read more >
Iterate Through a JSON Response in JSX Render for React
Building scalable apps requires handling and displaying JSON responses. This guide covers how to loop over an array of objects and render ......
Read more >
Iterate over JSON array to render components from your ...
I want to render components dynamically depending on an array stored in a local JSON file. At this point, you can say, “Man,...
Read more >
Array Example - JSON Forms
The array renderer is used, when an object with type array is used. To get a good overview, have a look at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found