1

Simply trying to make a default selected value in Angular but thus far I am having no luck.

HTML Before Compile:

<select ng-options="select.Value as select.Name for select in ruleSelect" ng-model="rule.MatchLogic" ng-init="rule.MatchLogic = 0" ></select>

HTML In Browser Source:

<select ng-options="select.Value as select.Name for select in ruleSelect" ng-model="rule.MatchLogic" class="ng-pristine ng-valid">
<option value="?" selected="selected"></option>
<option value="0">All</option>
<option value="1">At Least</option>
<option value="2">At Most</option>
</select>

How do I make value=0 (All) the default selected value.

allencoded
  • 7,015
  • 17
  • 72
  • 126

1 Answers1

2

All you need to do is set your ng-model value rule.MatchLogic to equal the corresponding value in the options. The options you use are ruleSelect.

So for example, set rule.MatchLogic = ruleSelect[someSelector].Value; inside your controller.

Matt Way
  • 32,319
  • 10
  • 79
  • 85