2

I am trying to use a custom Pipe declaration to search and filter elements in a list. But I get the following error and can not figure out why.(I am using angular2-seed project as the base project)

Error:

platform-browser.umd.js:1900 EXCEPTION: Error: Uncaught (in promise): No Pipe decorator found on SearchPipe

Pipe class code:

import { Pipe,PipeTransform } from 'angular2/core';
import { User } from './user';
@Pipe({
   name: 'search'
})
export class SearchPipe implements PipeTransform {
transform(value, [searchterm]) {
   if (value === undefined) {
      return value;
   } else {
      return value.filter((user:User) => user.Name.toLowerCase().includes(searchterm.toLowerCase()));
   }
 }
}

Component class code:

import {SearchPipe} from './users.search-pipe';

@Component({
    selector: 'users',
    moduleId: module.id,
    templateUrl: './users.component.html',
    styleUrls: ['./users.component.css'],
    pipes: [SearchPipe]
})

export class UsersComponent implements OnInit {
    .........
}
chamalabey
  • 457
  • 5
  • 12

0 Answers0