I'm creating a simple custom pipe which doesn't seem to work:
This is my code in the pipe which I created by the CLI:- (contain.pipe.ts)
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'contain'
})
export class ContainPipe implements PipeTransform {
transform(likes: any, term: any): any {
for (var i = 0; i < likes.length ; i++) {
if (likes[i] === term) {
return "liked";
}else{
return "";
}
}
}
}
Here's my component simply trying to output liked or not:- (recipe.component.html)
<h2>{{ [1,12,3] | contain:12}}</h2>
It doesn't seem to output any data, even if it's true!