Select default option value from typescript angular 6

前端 未结 14 1631
轻奢々
轻奢々 2020-12-09 07:30

I have a select html like this:


  
  

for the regular available options I'm using a sortedProps Array to provide option choices. But that's not the important part here.

What did the trick for me is setting value="undefined" to let the angular-model-binding (?) select this option automatically when in creationMode. Not sure if its a hack, but does exactly what i want. No addtionally typeScript necessary.

Additionally, sepcifing hidden makes sure the option in my case is not selectable, while required makes sure the form is invalid unless something gets selected there.

提交回复
热议问题