AngularJS - value attribute for select

前端 未结 8 1895
时光取名叫无心
时光取名叫无心 2020-12-02 09:32

Source JSON data is:

[
  {\"name\":\"Alabama\",\"code\":\"AL\"},
  {\"name\":\"Alaska\",\"code\":\"AK\"},
  {\"name\":\"American Samoa\",\"code\":\"AS\"},
           


        
8条回答
  •  旧巷少年郎
    2020-12-02 10:10

    If the model specified for the drop down does not exist then angular will generate an empty options element. So you will have to explicitly specify the model on the select like this:

    
    
    
    or
    
    
    

    Note that there is no empty options element in the select.

提交回复
热议问题