NejcZdovc / ng2-select2

Select 2 wraper for angular2
MIT License
123 stars 93 forks source link

Changing value dynamically only works first time #108

Open renan-ti opened 7 years ago

renan-ti commented 7 years ago

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
MinsuLim commented 6 years ago

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

Gummiees commented 6 years ago

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.