A
A
Alexander Belov2017-03-22 00:22:22
JavaScript
Alexander Belov, 2017-03-22 00:22:22

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;
}

html code:
<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>

I get an error PipeTransform is not defined . I can't figure out why.
Imported into the PipeTransform component, into the module too:
@NgModule({
  imports:      [ BrowserModule, HttpModule, routing],
  declarations: [ AppComponent, 
  				  HomeComponent, 
  				  PlacesComponent, 
  				  Pipe,
  				  PipeTransform],
  bootstrap:    [ AppComponent ]
})

True, Pipe is highlighted in a different color (in Sublime Text 3) for some reason, but the compiler has no complaints about it, it seems.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question