[Angular2]: How to save pipe model manipulation of *ngFor with pipes? - "#item of (result = (items | orderAsc))" doesn't work in A2

104 views
Skip to first unread message

HansMeise

unread,
Jan 27, 2016, 7:19:21 AM1/27/16
to AngularJS
So I populate a table with *ngFor and use pipes to filter and order the given array. This works perfectly and the table rows are created as expected. But I also wan't to use the result of the pipes in my component hosting the table. How can this be achieved with angular2?

html:
<tr *ngFor="#item of items | orderAsc">{{item.name}}</tr>

the angularJS way:
<tr *ngFor="#item of (result = (items | orderAsc))">{{item.name}}</tr>
where "result" could be used in the corresponding controller.

What is the angular2 way of achieving this?

Eric Martinez

unread,
Jan 27, 2016, 7:37:25 AM1/27/16
to AngularJS
Filter those items in your component class, then you pass that filtered array to your ngFor, that way you'll have it in both your component class and ngFor.
Reply all
Reply to author
Forward
0 new messages