angular-ngrx-refactoring
angular-ngrx-refactoring copied to clipboard
Filter not working
Hi,
I have found a mistake in your code.
Please, consider this statment: .filter((n: any) => { return n.payload.event.url.indexOf('flight') })
The indexOf method returns the index of the element or -1 if the element not exists. However, your filter expects a boolean value (true or false), so under the hood, the value will be converted to boolean. But if you check Boolean(-1) it returns true. Therefore this filter will always return true.
To make it works you have to compare it with -1: .filter((n: any) => n.payload.event.url.indexOf('flight')) !== -1