Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

$filter('filter')(array, expression) does not work with more than one nested property #9698

Closed
@barroudjo

Description

@barroudjo

My Array:

var array = [{
    length : 10,
    answerer : {
         email : '[email protected]',
         name : 'test user'
    }
},
{
    length : 20,
    answerer : {
        email : '[email protected]',
        name : 'admin'
    }
}];

the filter expression:

var expression = {
    answerer : {
        name : 'test',
        email: 'adm'
    }
};

Then filtering based on this:

var filteredData = $filter('filter')(array, expression)

I expect to get the empty array. However I get the full array, as if no filtering was done !
But if I filter on only one element, for example:

var expression = { answerer : { email: 'adm' } };

It works as expected and returns only the second element of array.

I also tried to define differently my filter expression:

var expression = { 'answerer.email': 'adm' } };

But this returns no result at all.

So it would seem there is a bug when filtering on more than one nested property.

A workaround could be to use a custom comparator functions. Any other ideas (besides flattening my array...) ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions