Skip to main content
Remove javascript and template tags. Add syntax highlighting and fix indentation.
Source Link
Edric
  • 26.6k
  • 13
  • 86
  • 95

My template looksI'm getting an error as follows,

template:

    <input #input placeholder="Search" id="search">
    <divCannot class="item"read *ngFor="letproperty item'filter' of data | searchPipe: inputundefined.value">
      {{item}}
    </div>

and i have component for SearchPipeComponent template:

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
      searchTerm = searchTerm.toUpperCase();
      return data.filter(item => {
        return item.toUpperCase().indexOf(searchTerm) !== -1 
      });
  }
}
<input #input placeholder="Search" id="search">
<div class="item" *ngFor="let item of data | searchPipe: input.value">
  {{item}}
</div>

what isPipe code:

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
    searchTerm = searchTerm.toUpperCase();
    return data.filter(item => {
      return item.toUpperCase().indexOf(searchTerm) !== -1 
    });
  }
}

What causes the issue hereerror?

My template looks as follows,

template:

    <input #input placeholder="Search" id="search">
    <div class="item" *ngFor="let item of data | searchPipe: input.value">
      {{item}}
    </div>

and i have component for SearchPipe

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
      searchTerm = searchTerm.toUpperCase();
      return data.filter(item => {
        return item.toUpperCase().indexOf(searchTerm) !== -1 
      });
  }
}

what is the issue here?

I'm getting an error as follows:

Cannot read property 'filter' of undefined.

Component template:

<input #input placeholder="Search" id="search">
<div class="item" *ngFor="let item of data | searchPipe: input.value">
  {{item}}
</div>

Pipe code:

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
    searchTerm = searchTerm.toUpperCase();
    return data.filter(item => {
      return item.toUpperCase().indexOf(searchTerm) !== -1 
    });
  }
}

What causes the error?

deleted 13 characters in body
Source Link
Daniel A. White
  • 190.7k
  • 49
  • 377
  • 462

My template looks as follows,

template: <input #input placeholder="Search" id="search"> <div class="item" *ngFor="let item of data | searchPipe: input.value"> {{item}} </div>,

    <input #input placeholder="Search" id="search">
    <div class="item" *ngFor="let item of data | searchPipe: input.value">
      {{item}}
    </div>

and i have component for SearchPipe

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
      searchTerm = searchTerm.toUpperCase();
      return data.filter(item => {
        return item.toUpperCase().indexOf(searchTerm) !== -1 
      });
  }
}

what is the issue here?

My template looks as follows,

template: <input #input placeholder="Search" id="search"> <div class="item" *ngFor="let item of data | searchPipe: input.value"> {{item}} </div>,

and i have component for SearchPipe

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
      searchTerm = searchTerm.toUpperCase();
      return data.filter(item => {
        return item.toUpperCase().indexOf(searchTerm) !== -1 
      });
  }
}

what is the issue here?

My template looks as follows,

template:

    <input #input placeholder="Search" id="search">
    <div class="item" *ngFor="let item of data | searchPipe: input.value">
      {{item}}
    </div>

and i have component for SearchPipe

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
      searchTerm = searchTerm.toUpperCase();
      return data.filter(item => {
        return item.toUpperCase().indexOf(searchTerm) !== -1 
      });
  }
}

what is the issue here?

Source Link
Sajeetharan
  • 222.3k
  • 65
  • 364
  • 407

Cannot read property 'filter' of undefined

My template looks as follows,

template: <input #input placeholder="Search" id="search"> <div class="item" *ngFor="let item of data | searchPipe: input.value"> {{item}} </div>,

and i have component for SearchPipe

@Pipe({
  name: 'searchPipe',
  pure: false
})
export class SearchPipe implements PipeTransform {
  transform(data: any[], searchTerm: string): any[] {
      searchTerm = searchTerm.toUpperCase();
      return data.filter(item => {
        return item.toUpperCase().indexOf(searchTerm) !== -1 
      });
  }
}

what is the issue here?