Encapsulating text filter
A method for checking if a text contains a fragment.
Before finishing this section, let's just make two improvements. First, we are finding products whose name
contains a received text. Well, this behavior is quite common, and is probably going to appear elsewhere at some moment. So, it would be interesting to encapsulate this logic. Let's then begin by creating a service for filtering.
In it, we may create a method called contains()
, which is a simple and intuitive name. If we also check there if the text
exists, we avoid having to manually return undefined.
Now, we just need to inject the filteringService
and use it.
Commit - Method to check if field contains text
Last updated