title: angular2 pipe not working
body: <p>I am trying to have search functionality in angular2.</p>
  
  <p>So far i have created my own custom pipe for this like below:</p>
  
  <p><strong>search.pipe.ts</strong></p>
  
  <pre><code>import { Pipe, PipeTransform ,Injectable} from '@angular/core';
  
  @Pipe({
      name: 'search',
      pure: false
  })
  @Injectable()
  export class SearchPipe implements PipeTransform {
      transform(components: any[], args: any): any {
          var val = args[0];
          if (val !== undefined) {
              var lowerEnabled = args.length &gt; 1 ? args[1] : false;
  
              // filter components array, components which match and return true will be kept, false will be filtered out
              return components.filter((component) =&gt; {
                  if (lowerEnabled) {
                      return (component.name.toLowerCase().indexOf(val.toLowerCase()) !== -1);
                  } else {
                      return (component.name.indexOf(val) !== -1);
                  }
              });
         }
         return components;
      }
  }
  </code></pre>
  
  <p>and after doing this I am trying to apply this pipe inside html like this:</p>
  
  <pre><code>*ngFor="let aComponent of selectedLib.componentGroups[groupCounter].components | search:searchComp:true"
  </code></pre>
  
  <p>its giving me below error:</p>
  
  <blockquote>
    <p>TypeError: Cannot read property '0' of undefined</p>
  </blockquote>
  
  <p>when I am not applying pipe , *ngFor prints the array elements correctly but as soon as I am applying search pipe in html its giving me above error.</p>
  
  <p>any inputs?</p>