Skip to content

Trouble using filters on complex objects #38

@Rodeoclash

Description

@Rodeoclash

I'm trying to use the reverse filter on a set of complex objects which can't be serialised to JSON due to cyclic structures (although I'm not sure if this has any link to the problem I'm having).

Currently I'm using:

ng-repeat="response in collection.data.slice().reverse() track by response.element.id"

To reverse the array. The "track by" avoids infinite digest loops. If I change the code to use your reverse filter:

ng-repeat="response in collection.data | reverse track by response.element.id"

I begin to get infinite digest errors. The problem I think stems from reversing the array in place which confuses Angular's dirty tracking.

Any thoughts? I'm not quite where the problem lies with the implementation. My instinct is that a new array containing references to the objects should be returned from the filters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions