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.

Error when adding pipe to for loop

See original GitHub issue

I am getting an error when I add groupBy pipe on a for loop <div class="row" *ngFor="let tsk of tsks | groupBy: 'MilestoneName'">

And the error that throws is Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.

The array that I looping through is an Array

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
danrevahcommented, Mar 7, 2017

The last piece of code that I wrote works perfectly for this data structure: Make sure you copying it properly.

tsks = [{
      CompletedFlag: true,
      ProgressFlag: false,
      DueDate:"2014-10-02T13:12:37.027",
      Signup: "2014-10-04T11:51:10.137",
      ObMilestone: 1,
      ObTask: 119,
      AssignedToId: 0,
      Company: "ABC Corp",
      Description: "Lorem Ipsum",
      Favourite: null,
      FirstName: "Libin",
      LastName: "J",
      MilestoneName: "Blue",
      OnboarderStatus: "Live",
      Partner : null
    },
    {
     CompletedFlag: true,
      ProgressFlag: false,
      DueDate:"2014-10-02T13:12:37.027",
      Signup: "2014-10-04T11:51:10.137",
      ObMilestone: 1,
      ObTask: 119,
      AssignedToId: 0,
      Company: "ABC Corp",
      Description: "Lorem Ipsum",
      Favourite: null,
      FirstName: "Libin",
      LastName: "J",
      MilestoneName: "Blue",
      OnboarderStatus: "Live",
      Partner : null
    }];
<div class="row" *ngFor="let task of tsks | groupBy: 'MilestoneName' | pairs">
  <div>Group milestone name: {{task[0]}}</div>

  <div class="row" *ngFor="let t of task[1]">
    <div>Task: {{t.FirstName}}</div>
  </div>
</div>
3reactions
danrevahcommented, Mar 9, 2017

Try using the pairs pipe:

<div class="row" *ngFor="let task of tsks | groupBy: 'MilestoneName' | pairs">
    <div>Group milestone name: {{task[0]}}</div>

   <div class="row" *ngFor="let t of task[1]">
      <div>Task: {{t}}</div>
   </div>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Bash for loop syntax error with pipe - Stack Overflow
I've tried wrapping my qstat command in various quotes and brackets to no avail, what am I doing wrong? bash.
Read more >
21 Iteration | R for Data Science - Hadley Wickham
Once you master the vocabulary of FP, you can solve many common iteration problems with less code, more ease, and fewer errors.
Read more >
why doesn't a bash while loop exit when piping to terminated ...
It is due to a choice in implementation. Running the same script on Solaris with ksh93 produces a different behavior: $ while /usr/bin/true...
Read more >
Any simple way to do for loop pipe , such as ` ls | grep ".*.7z ...
# 1 command with option [for loop pipe] command with option | command with option # 2 command with option [for loop pipe]...
Read more >
Adding search results to a table in a for loop... can I pipe?
I'm doing a sequence of searches in a for loop and putting the results ... Doing so will eventually result in a cannot...
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