Set default value in select when the ng-model is null

前端 未结 8 2140
悲哀的现实
悲哀的现实 2021-02-05 10:33

I\'m new to angular and i\'m trying to set a default state to select when my ng-model is null. Basically I want to set it to \'None\' if the model is empty. I tried the below co

8条回答
  •  孤街浪徒
    2021-02-05 11:28

    What you are looking for is undefined.

    If the value is undefined do you need a value to go to the database when 'none' is selected?

    If sending an empty is acceptable you may consider the following:

    
    

    Fiddle

    This allows you to pass in a value as well and use the same form for edits and new records.

提交回复
热议问题