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.

I’m submitting a … (check one with “x”)

[ ] bug report => check the FAQ and search github for a similar issue or PR before submitting
[X] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

I have this code

<div *ngFor="let service of services">
    <span><img  [src]="service.imgPath" alt="{{ service.name }}"/></span>
    <h4>{{ service.name}}</h4>
    <p>{{ service.desc }}</p>
</div>

And .json file

"service":[
    { "name" : "someName1", "desc" : "someDesc1"},
    { "name" : "someName2", "desc" : "someDesc2"},
    { "name" : "someName3", "desc" : "someDesc3"}
  ]

How can I do translation of each service that have 2 parameters

In regular case I use {{ ‘something’ | translate }} , where “something” is placed in .json file

“something” : “translation” So how can a use it in state of ngFor? It read me an object from .json, but not array of objects that what I need in my case

  • ngx-translate version: 7.0.0

  • Angular version: 4.0.0

  • Browser: [all]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:15

github_iconTop GitHub Comments

7reactions
ocombecommented, May 8, 2018

Hello, I’m closing this issue because it’s too old. If you have a similar problem with recent version of the library, please open a new issue.

3reactions
megustalafantabienfriacommented, Dec 30, 2018

Not working,

ERROR Error: Cannot find a differ supporting object ‘service’ of type ‘string’. NgFor only supports binding to Iterables such as Arrays.

That’s weird… because that’s how my project is working. I’m using it like this

<div *ngFor="let service of ('service' | translate)">
	<p>{{service.name}}</p>
	<p>{{service.desc}}</p>
</div>

The json is structured like this

{
  "service": [
    { "name" : "someName1", "desc" : "someDesc1"},
    { "name" : "someName2", "desc" : "someDesc2"},
    { "name" : "someName3", "desc" : "someDesc3"}
  ]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular NgFor Issue - typescript - Stack Overflow
I am trying to display the list of the object having id and name using NgFor directive but i am getting below ...
Read more >
Angular ngFor - Learn All Features, Not Only For Arrays
Let's learn a ton of hidden ngFor features that are not often ... still run into performance issues and notice that the UI...
Read more >
Problem with ngFor · Issue #8602 · angular/angular - GitHub
I got this error: Cannot assign to a reference or variable! ... testItems is an array of string. If it was an array...
Read more >
NgForOf - Angular
The ngForOf directive is generally used in the shorthand form *ngFor . In this form, the template to be rendered for each iteration...
Read more >
Angular Ngfor Issue - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
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