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.

Filters for nested objects not working #6222

Closed

Description

@anirvan-majumdar

Hi,

I recently changed my applications angular dependency from 1.2.10 to 1.2.12. And the first thing I observed is that some of the filters I'm using for a data table have stopped functioning. A closer inspection revealed that the filters have stopped working for all those properties which are nested one level.

For example, if the object being rendered for every row is such—

{  
   p1: "...",
   p2: "...",
   p3: { name: "..." },
   p4: { name: "..." }
}

Then the filters on p1 and p2 work just fine, but those for p3 and p4 stopped working.

Reverting the version to 1.2.10 fixes the issue.

Activity

  1. pkozlowski-opensource commented on Feb 13, 2014

    @pkozlowski-opensource
    Member

    @anirvan-majumdar I think it was fixed in master via b4eed8a but we would need a plunk to confirm. Could you please test on your side with the latest snapshot from master (http://code.angularjs.org/snapshot/) or provide a plunker with the reproduce scenario?

  2. anirvan-majumdar commented on Feb 14, 2014

    @anirvan-majumdar
    Author

    Here's the plunker that depicts the issue — link

    If you change the referenced library from 1.2.12 to 1.2.10, then everything will work fine with the filters.

  3. Narretz commented on Mar 9, 2014

    @Narretz
    Contributor

    Here's the plunker with 1.2.14:

    http://plnkr.co/edit/uB7Mta?p=preview

    With the new syntax, the filtering works, but initially when the page loads and the nested filter variable is undefined or null, the filter returns 0 results. When you type in the input, the filtering works - also when you clear the input, which sets the variable to empty string. The filtering also works if you initialize the filter variable as emtpy string in the controller.

    When you have a non-nested filter an undefined variable returns the whole collection (null is a special case which returns nothing in all cases, I think).

  4. added this to the milestone on Jul 1, 2014
  5. gkalpak commented on Oct 25, 2014

    @gkalpak
    Member

    As @Narretz mentioned, this works as expected in the latest versions (1.2.26, 1.3.0).
    This should be probably closed.

    Regarding the issue brought up by @Narretz (#6222 (comment)), the problem can also be solved by using a search object and binding the inputs to properties of that object:

    <input type="search" ng-model="search.p1" />
    <input type="search" ng-model="search.p2" />
    
    <div ng-repeat="... | filter:search">...</div>
    

    Demo fiddle

  6. lgalfaso commented on Jan 7, 2015

    @lgalfaso
    Contributor

    with #6222 (comment), this can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions