I had the same problem recently. I solved this by adding a few things to the selection box and another entry to the array of possible choices.
First you want to add an empty or invalid selection to the list of possible choices, the best place in slot [0], and you will see why further down.
vm.distributors = [ "Select Distributor", "A", "B", "C" ];
Then you need to add and update some Angular directives for your selection field. You want ng-valid to tell Angular which is acceptable here. You also need to indicate that you are running a field with the value “select something else” and that it is not valid for this value, which must be selected at the time of sending. Adding a name and identifier is usually the best thing. The last bit to add is the ng-required directive, since you used novalidate on the form, but this form element needs to change to something real. The end result is below:
<div class="form-group col-lg-2 col-lg-push-1" ng-class="{'has-error' : vm.myDistr == vm.distributors[0] && frameVersionEditor.$dirty || frameVersionEditor.distributor.$pristine && frameVersionEditor.distributor.$touched}"> <label>Distributor</label> <select data-ng-model="vm.myDistr" id="myDistr" name="myDistr" ng-init="vm.distributors[0]" class="select form-control skinny" ng-required="true" data-ng-options="d for d in vm.distributors" ng-valid="vm.myDistr != vm.distributors[0]"></select> <p class="required" ng-show="vm.myDistr == vm.distributors[0]">*</p> <p class="good" ng-show="vm.myDistr != vm.distributors[0]">✔</p> <span ng-show="vm.myDistr == vm.distributors[0] && frameVersionEditor.$dirty || frameVersionEditor.distributor.$pristine && frameVersionEditor.distributor.$touched" class="help-block">Please select a distributor</span>
This has also been updated to illustrate the simplest implementation (since you use 0-4 as keys, you really don't need them, just use the base array). I also changed my code to match John Papa's best practices and added to the red star (for invalid choices) and the green tick (for the right choice), as well as other good practice (show success as well as failure) in case of non-English users .
You also do not need the initial parameter that you specified initially, since my updates do a great job of this.
Upon request, Plunker is located here .
Hope this helps.
-C§
CSS
source share