angular-pipes icon indicating copy to clipboard operation
angular-pipes copied to clipboard

this undefined within where pipe

Open Et3rnal opened this issue 6 years ago • 2 comments

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request

Current behavior

Using the where pipe to call the function I can't access this

num = 1
aEqualsOne(item) {
  return item.a === this.num;
}

If this is not a bug, how can I pass parameters to the pipe?

Et3rnal avatar Sep 12 '19 06:09 Et3rnal

I tried not to use it without the function I noticed in order for it to return any result. It has to find an exact match <= how can I change this? for example, 3 characters of the word is enough to return a match also it is case sensitive

Et3rnal avatar Sep 12 '19 06:09 Et3rnal

@Et3rnal you might have already found the answer, but the solution is to use arrow function instead:

num = 1
// declare as a normal public variable
aEqualsOne = (item) => {
  return item.a === this.num;
}

rosostolato avatar Apr 28 '21 20:04 rosostolato