I'm new to Angular2/Typescript and have been stuck on this for almost a day. I'm sure this must be something simple that I'm missing:
This is my view: noticias.html
<ion-list id="NewsList" no-margin>
<ion-item no-padding *ngFor="let item of newsData | newsfilter">
...
</ion-item>
</ion-list>
I need to filter that list in this newsfilter pipe.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'newsfilter'
})
export class NewsfilterPipe implements PipeTransform {
transform(array: any[]) {
console.log(array.length);
}
}
Right now, when I console.log the array, I get an array with a couple of objects in it, which is what I would expect.
However, and this is what's confusing me, when I console.log(array.length) I get "undefined is not an object (evaluating 'array.length'). I also can't access any keys in these objects like array[0].id, for example.
Can someone please help in explaining what I'm doing wrong here? Thanks in advance.