Thursday, September 17, 2015

Angular ng-options set selected value

        
We can set the default value for ng-options as shown below

Html



 <label for="cycles">Cycle:</label>
            <select id="cycles"
                    ng-options="option.Text for option in data.ExamCycles track by option.Value"
                    ng-model="SelectedCycle" class="form-control input-xxlarge">
                <option value='' disabled selected>Select Cycle..</option>
            </select>

Java script


        $scope.data = {
                           ExamCycles: response.ExamCycles,
                           SelectedExamSite:[]
                        }
       $scope.SelectedCycle = $scope.data.ExamCycles[0];


Output


No comments:

Post a Comment