Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

this undefined within where pipe #96

Open
Et3rnal opened this issue Sep 12, 2019 · 2 comments
Open

this undefined within where pipe #96

Et3rnal opened this issue Sep 12, 2019 · 2 comments

Comments

@Et3rnal
Copy link

Et3rnal commented Sep 12, 2019

[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
Copy link
Author

Et3rnal commented Sep 12, 2019

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

@rosostolato
Copy link

rosostolato commented Apr 28, 2021

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants