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

前端 未结 3 1340
醉酒成梦
醉酒成梦 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条回答
  •  不知归路
    2021-01-26 17:06

    DEMO

    var myapp = angular.module('myapp', []);
    myapp.controller('FirstCtrl', function ($scope) {
        $scope.regions = 
     [
          {
            name: "COLOMBIA",
            code: 5
          },
          {
            name: "ARGENTINA",
            code: 6
          },
          {
            name: "BRAZIL",
            code: 7
          }
      ];
      
      $scope.selectThisId={
        "id":6,
        "animal":'dog',
        "variable":'xxx32'
     };
     
     $scope.region=$scope.selectThisId.id;
    });
    
    

提交回复
热议问题