Select default option in a dropdown, save the value in the value attribute of the dropdown. Angular.js. Angular.js

前端 未结 3 1365
醉酒成梦
醉酒成梦 2021-01-26 16:31

I have seen infinity of post to try to choose by default an option in a dropdown. But I have not been able to achieve it. I have an array of some countries.

$sco         


        
3条回答
  •  萌比男神i
    2021-01-26 16:57

    Working demo: http://plnkr.co/edit/zhye91pDUEMgaZnXZGWE?p=preview

    You basically create a default region by doing

    $scope.select = $scope.selectThisId.id;
    $scope.regionSelected = {};
    

    then create a select tag with ng-options, binding it to the model, and calling ng-init on the model.

    
    

提交回复
热议问题