NejcZdovc / ng2-select2

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

[value] resets after updating the options #140

Open OlehPetrykUA opened 5 years ago

OlehPetrykUA commented 5 years ago
this.select2Host = [{ id: '', text: text }];
                    if (localStorage.getItem('selectedHost')) {
                        const selectedHost: Select2OptionData = JSON.parse(localStorage.getItem('selectedHost'));
                        this.select2Host.push(selectedHost);
                        this.currentHostIdFromStorage = selectedHost.id;
                    }
<select2
 [value]="currentHostIdFromStorage"
 [data]="select2Host"
</select2>

I take currentHostId from local storage, after that i load all options through the request and selected value becomes the first one

OlehPetrykUA commented 5 years ago

I found this PR https://github.com/NejcZdovc/ng2-select2/pull/134 Can you review it?