NejcZdovc/ng2-select2

Changing value dynamically only works first time

renan-ti opened this issue · 2 comments

This problem can be reproduced in ng2-select2-demo (4. Demo with a value changing):
https://nejczdovc.github.io/ng2-select2-demo/

  1. Click "Change value".
    Result: Selected value in select 2: car2
  2. Select car1.
    Result: Selected value in select 2: car1
  3. Click "Change value" again.
    Result: Selected value in select 2: car1
    Expected: Selected value in select 2: car2

I met the problem too.
I thing it's a bug. Is the anyway to fix the problem??

I thought the answer could be that the function which the button uses allways set the startValue to 'car2' as you can see here.

However, the solution to this I think it would be
public changeValue() { this.startValue = this.exampleData[Math.floor(Math.random() * this.exampleData.length)].id; }
but it does not work either.