My goal seems simple using vanilla JS, but with AngularJS, I'm looking for the best way to achieve it within the framework. I aim to update the selected options in a multiple select box without adding or removing any options. Below is a snippet of my HTML:
<select multiple>
<option value="1">Blue</option>
<option value="2">Green</option>
<option value="3">Yellow</option>
<option value="4">Red</option>
</select>
With the following array, I want to dynamically select/deselect options from this list:
[{id:1, name:"Blue"},{id:4, name:"Red"}]
Upon setting this array in the scope, I expect the select box to deselect any options that are not Blue or Red and select Blue and Red. The usual advice is to use ng-repeat, but in my case, recreating the list every time is not viable since the selected values list is incomplete. It seems AngularJS lacks a direct mechanism for this, leaving me unsure how to proceed without having to resort to jQuery.