I have a <select>
element, which will possibly have a default <option>
set based on a condition - that condition being if another user has previously submitted the form and created the object being submitted. However, it seems I can't apply ng-if
to an Option element (or any tags) and I'm finding it hard to come up with a solution.
Currently, my code looks like:
<select
id="someId"
ng-options="(item?'Yes':'No') for item in [true, false]"
class="someClass"
ng-class="someMethodToGetDynamicClass('this')
ng-model="myObject.thisOption"
ng-disabled="valueCheckingIfThisObjectHasBeenPreviouslySubmitted">
<option ng-if="valueCheckingIfThisObjectHasBeenPreviouslySubmitted" selected>{{myObject.thisOption}}</option>
</select>
The selected option should only be set if valueCheckingIfThisObjectHasBeenPreviouslySubmitted
is true - this means someone else has submitted the form before, and so the value has been set and should only be displayed.