Datepicker filter error


Topic: Datepicker filter error

itkaufmann pro premium priority asked 3 years ago

It seems like it is not possible to access any ouside class data in the datepicker filter function.In the function, where I want to read the value of a class Object with this.anyObject, I get the error "Cannot read properties of undefined"

Both variables are set before the function is called. However, an undefined error occurs both times.

enter image description here

Example of when the error occurs:enter image description here

enter image description here

Actual wanted implementation:enter image description here

enter image description here


Arkadiusz Idzikowski staff commented 3 years ago

@itkaufmann Could you provide a more detailed description of the problem with code snippets?


itkaufmann pro premium priority commented 3 years ago

I just added code snippets


Arkadiusz Idzikowski staff answered 3 years ago

There is probably a problem with this context. Please try to create the filter function as an arrow function instead of class method:

  filterFunction = (date: Date): boolean => {
    ...
  }

itkaufmann pro premium priority commented 3 years ago

Nice it's working, thank you!


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 2.0.0
  • Device: any
  • Browser: any
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No
Tags