Looking for assistance with this code snippet:
<select ng-model='item.data.choice' >
<option ng-if='item.data.simple_allow_blank == false' ng-show='choice.name' ng-repeat='choice in item.data.simple_choices' value="{{choice.name}}" ng-disabled="$parent.controllerAction == 'show'">{{choice.name}}</option>
</select>
The code displays 3 choices specified by the system administrator in a dropdown menu, excluding any blank options.
The issue arises when I try to set a default value (e.g. choice[0]
) as it results in an extra blank option being included.
I attempted to follow advice provided in this Stack Overflow question on switching from ng-repeat
to ng-options
.
In my case, despite having a dynamic list of choices including 1, 2, 3, and a blank option, removing the blank proved challenging while ensuring an initial default value was selected. Using ng-options
introduced the unwanted blank entry each time a new list was generated, while reverting to ng-repeat
removed the Blank option but lacked the ability to set an initial value from the dynamic list.
Although I can assign a default value, eliminating the blank option remains elusive. Any insight or guidance would be greatly appreciated. Thank you.