Why does ng-selected not work with ng-repeater?

前端 未结 2 1414

Why is this repeater broken


                        
    
提交评论

  • 2021-01-20 21:55

    stick with ng-options

    <div ng-app>
      <h2>Todo</h2>
      <div ng-controller="QuarterController">
        <select name="quarter" ng-model="Quarter" ng-options="obj.value as obj.text for obj in [{'value': 1,'text' : 'Q1'},{'value':2,'text':'Q2'},{'value':3,'text':'Q3'},{'value':4,'text':'Q4'}]">
        </select>
      </div>
    </div>
    
    function QuarterController($scope) {
        $scope.Quarter = 2;
    }   
    

    http://jsfiddle.net/hDNsm/3/

    you might as well define the array in your controller

    0 讨论(0)
  • 提交回复
    热议问题