Answer the question
In order to leave comments, you need to log in
Where did PipeTransform is not defined / Angular 2 get lost?
I'm trying to write a search filter in an Angular2 application.
ts code:
import { Component } from '@angular/core';
import { Pipe,PipeTransform } from '@angular/core';
@Pipe({
name: 'searchFilter'
})
export class SearchFilter implements PipeTransform {
transform(items: any[], criteria: any): any {
return items.filter(item => {
for (let key in item ) {
if((""+item[key]).includes(criteria)){
return true;
}
}
return false;
});
}
}
@Component({
selector: 'releases-component',
templateUrl: './app/releases/releases.component.html',
styleUrls: ['./app/releases/releases.component.css']
})
export class ReleasesComponent {
this.releases;
}
<div class="menu">
<div class="search">
<input type="text" placeholder="Search for places of interest here">
</div>
</div>
<div class="resultsOutlet">
<ul>
<li *ngFor="let place of (places | searchFilter: search.value )">(...)</li>
</ul>
</div>
@NgModule({
imports: [ BrowserModule, HttpModule, routing],
declarations: [ AppComponent,
HomeComponent,
PlacesComponent,
Pipe,
PipeTransform],
bootstrap: [ AppComponent ]
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question