I wrote my own filter pipe as it disappeared in angular2:
import {Pipe, PipeTransform} from \'angular2/core\';
@Pipe({
name: \'myFilter\'
})
export class
original
AFAIK there is currently no way to do this directly. A hack would be to add a template variable to the content and use a ViewChildren(...)
query to get the created items and count them.
...
count: {{filteredItems?.length}}
@ViewChildren('someVar') filteredItems;
An alternative approach would be to pass a reference to a counter variable to the pipe like shown in https://plnkr.co/edit/Eqjyt4qdnXezyFvCcGAL?p=preview
update (Angular >=4.0.0)
Since Angular 4 *ngFor
supports as
which you can use in the template (inside the element that *ngFor
is added to) like
{{result?.length}}
- 热议问题