javascript - How to bind default value for select with required attribute in AngularJS if this value doesn't exist? -


i have select element this:

<select name="profiletype"         ng-model="profiletypeoptions.selectedoption"         ng-init="profiletypeoptions.selectedoption=profiletypeoptions.user_types[0]"         ng-options="option option.title option in profiletypeoptions.user_types"         required> </select> 

as can see, used ng-init here , takes existing value json object got. form valid, because option selected , value defined. possible implement default value here (see below)?

<select name="profiletype"         ng-model="profiletypeoptions.selectedoption"         ng-init="'please select'" <-- default value here, option not selected, form invalid         ng-options="option option.title option in profiletypeoptions.user_types"         required> </select> 

how force form assume option in select not selected?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -