<option value="? undefined:undefined ?" selected="selected"></option>

< option value="? undefined:undefined ?" selected="selected" >

Why does AngularJS include an empty option in select?
Adding ng-model to predefined Select element adds undefined option -

AngularJs overrides the "selected" property when we bind the select to a model. If we inspect the rendered DOM we will find that a new item has been added i.e.

 <option value="? undefined: undefined ?"></option>

I think ?undefined:undefined ? should not be set as value. When a user choose nothing they ? undefined: undefined ? will be submitted as value.

You could just initialize it using ng-init such as in the below examples.

Defining that model in the controller -

<script>
    var myApp = angular.module('myApp', [])
        .controller('MyCtrl', ['$scope', function ($scope) {
            $scope.selectedOption = 1;
        }]);
</script>

And other example is -
<div ng-init="selectedOption=1">#TODO</div>

And it looks like -
<select ng-model="selectedOption" required="required" ng-init="selectedOption='1'"
        ng-options="option.value as option.name for option in typeOptions"></select>

Other one example is -
<select ng-model="selectedOption" required="required"
        ng-options="option.value as option.name for option in typeOptions">

    <option style="display:none" value="">select a type</option>
</select>

Other one example is -
<select ng-options="option.value as option.name for option in typeOptions">
    <option value="" ng-if="false"></option>
</select>
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - https://code-sample.com and https://code-sample.xyz
My Book1 - BEST SELLING ANGULAR BOOK (INCLUDING ALL VERSIONS 2, 4, 5, 6, 7)
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide.

www.code-sample.com/. Powered by Blogger.
^