1

I recently updated angular from 1.1.5 to 1.2.14.

Now the filters in the ng-repeats produce some unexpected behavior:

  1. ng-repeat renders as normal

  2. enter text into filter model input : ng-repeat does not filter

  3. remove text from input and angular adds extra dom elements to the ng-repeat, basically repeating the ng-repeat. The array bound to the ng-repeat does not change though.

  4. repeating steps 2 and 3 causes more elements to be added

I have tried to recreate this in PLUNKR and it works fine. Any idea what could be causing this?

code:

<input type="text" data-ng-model="query" >

<div class="default-add" data-ng-repeat="array in arrays.arrays | orderBy:'name' | filter:{name: query}">
    <div class="default-add-image">
       <h1>{{array.title}}</h1>
    </div>
</div>

The data is valid json, I have tested with mock data and have the same error.

Thanks

2
  • Share your code, it's really hard to guess what's wrong without it. Commented Apr 3, 2014 at 8:35
  • I add the same issue and solved it in the same manner. i had 2 nested ng-repeat <ul ng-repeat=".."> <li> <ul ng-repeat=".."> <li> ..</li> </ul> </li></ul> Commented Sep 19, 2015 at 17:23

2 Answers 2

2

Removing the NG-REPEAT from the repeated element and adding it to a parent container solved it.

Sign up to request clarification or add additional context in comments.

1 Comment

I add the same issue and solved it in the same manner. i had 2 nested ng-repeat <ul ng-repeat=".."> <li> <ul ng-repeat=".."> <li> ..</li> </ul> </li></ul> any ideas why this happens ?
0

If it is running in Plunker fine, then most likely the problem lies in your code. Is this a custom filter? If yes, I would start looking there. If not, then I would check if it works properly on artificial data (thinking that the data might be the issue). If this does not work, then look at your data provider. If this works, then look into how you are processing the data.

I doubt that this is Angular's bug. I migrated from 1.0.7 to 1.2.x recently without such problem (there were few, but all fixed easily by following migration guidelines from Angular team).

Hope that helps!

4 Comments

Updated answer with some comments
What will happen if you remove | orderBy:'name' | filter:{name: query} from the ng-repeat directive? Will it show results properly then?
Yes, the error only occurs when the filter is applied.
Which elements are added to the DOM? Can you add them to the ticket description?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.