AngularJs - ng-model in a SELECT

后端 未结 6 1100
执念已碎
执念已碎 2020-12-23 15:58

JSfiddle

Problem:

I have a SELECT-element in my page, which is filled in with an ng-repeat. It also has a ng-model

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-23 16:57

    try the following code :

    In your controller :

     function myCtrl ($scope) {
          $scope.units = [
             {'id': 10, 'label': 'test1'},
             {'id': 27, 'label': 'test2'},
             {'id': 39, 'label': 'test3'},
          ];
    
       $scope.data= $scope.units[0]; // Set by default the value "test1"
     };
    

    In your page :

     
    

    Working Fiddle

提交回复
热议问题