I've been having an issue trying to use pipes in Ionic 2. Here is my error:
Uncaught Error: No Directive annotation found on MapToIterable(…)
I've generated a pipe using the Ionic 2 CLI and have edited it to accomplish some functionality where I can iterate over an object of objects, via *ngFor. Here is my Pipe code:
import { Injectable, Pipe } from '@angular/core';
@Pipe({
name: 'mapToIterable'
})
@Injectable()
export class MapToIterable {
transform(value: any): any {
if(value === null) {
return null;
} else {
return Object.keys(value).map(key => value[key]);
}
}
}
Here is the *ngFor loop in my template:
<div *ngFor="let video of (user.videos | mapToIterable)">
<img src="{{video.thumbnail}}" />
</div>
I'm not sure why I'm getting this issue. I've imported the Pipe correctly inside of my @NgModule declarations, yet no matter anything else I've tried, I still run into this error.
Does anyone have any idea?
Thanks!
@Pipeand@Injectable? - jonrsharpeionic g pipe map-to-iterable- Stevie Star@Pipe, and@Injectableis for e.g. services. - jonrsharpe