Angular2 listing, submitted / filtered ng Per Results

Hi guys, I got a ng2 page with several * ngFor nested for each using pipes. I want to get a list of internal elements to do an action for all of them,

something like that:

<div *ngFor="let a of b | x |y | z">
  <div *ngFor="let c of a  | x |y | z">
    <div *ngFor="let d of c">
      <div [service]="(d.item|async)"></div>
    </div>
  </div>
</div>

I want to list all d.item in one list and call a method on it.

+4
source share
1 answer

found a solution

export class component  {

  @ViewChildren('myVar') createdItems;

  showChildren() {
    console.log(this.createdItems.toArray().length);
  }
  }
<div *ngFor="let a of b | x |y | z">
  <div *ngFor="let c of a  | x |y | z">
    <div *ngFor="let d of c">
      <my-component #myVar [service]="(d.item|async)"></div>
    </div>
  </div>
</div>
Run code
+2
source

Source: https://habr.com/ru/post/1675768/


All Articles