2

After I updated my angular 2 projet from RC4 to 2.0.1 I'm having a problem with a ngFor looping on an array of objects (It was working fine on RC4)

the list of sorted objects is not being updated properly on the DOM, they seem unsorted.

Steps to reproduce the bug /issue:

  1. here is the plnkr: plnkr
  2. Move the start/ stop bounds through the middle.
  3. Then move the draggable bar to the left / right.
  4. You'll see the elements displayed are being updated.
  5. At some point if you move to the left you'll see the elements being unsorted/mixed.
  6. I added on console log the id index from ngLoop. so you can see its unsorted when the problem occurs

I tried several things, but nothing worked:

  • using a copy on the object
  • using an array with the keys...

thank you for your help

viceo
  • 36
  • 3
  • After checking angular 2 release updates I see where the problem comes from: added in RC5 --> "core: ensure ngFor only inserts/moves/removes elements when necessary" I compared my projects RC4 and 2.0.1 and all elements are being updated only on RC4 (as expected). there is a way to bypass this? and have all DOM elements updated after change in ngfor on 2.0.1 ?? – viceo Oct 04 '16 at 09:26

1 Answers1

0

In order to get all DOM elements/objects inside ngfor updated:

I had to create a new component, and then instanciate the component inside the ngfor.

now elements are properly updated as they were in RC4...

viceo
  • 36
  • 3
  • 1
    Can you give some example code? Maybe it's related to my problem: http://stackoverflow.com/questions/41185017/angular2-doesnt-detetect-changes-in-array – SoS Dec 16 '16 at 13:05