不能使用angular.js和php设置下拉列表中的值


Can not set the value in drop down using angular.js and php

我面临一点问题,将数据设置为从数据库获取后的下拉选择值。我在下面解释我的代码。

plan.html:

<div class="input-group bmargindiv1 col-md-12">
 <span class="input-group-addon ndrftextwidth text-right" style="width:180px">Date :</span>
<datepicker date-format="MMMM d, y" date-min-limit="2010/01/01" date-max-limit="2020/01/01"button-prev='<i class="fa fa-arrow-circle-left"></i>' button-next='<i class="fa fa-arrow-circle-right"></i>'> 
<input type="text" name="birthdate" class="form-control" ng-model="date" placeholder="Add date" />
 </datepicker>
</div> 
<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Topic :</span>
<input type="text" name="topic" class="form-control" ng-model="topic" placeholder="Add Topic" />
</div> 
<div class="input-group bmargindiv1 col-md-12">
<span class="input-group-addon ndrftextwidth text-right" style="width:180px">Section:</span>
<select id="coy" name="coy" class="form-control" ng-model="section" ng-options="sec.name for sec in listOfSection track by sec.value " >
<option value="">Select section</option>
</select>
</div>

相关控制器文件代码如下:

$scope.listOfSection=[];
    $http({
        method:'GET',
        url:"php/userplan/getSectionData.php",
        headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
    }).then(function successCallback(response){
        angular.forEach(response.data,function(obj2){
            var data={'name':obj2.section_name,'value':obj2.section_id};
            $scope.listOfSection.push(data);
        });
    },function errorCallback(response) {
    });
$http({
            method:'POST',
            url:"php/userplan/editPlanData.php",
            data:planid,
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        }).then(function successCallback(response){
            $scope.date=response.data[0].date;
            $scope.topic=response.data[0].topic;
            $scope.section=response.data[0].section_id;
            $scope.buttonName="Update";
            $scope.showCancel =  true;
        },function errorCallback(response) {
        });

这里response.data[0].section_id应该在下拉菜单中设置为值,并且应该显示相应的名称。在这里,我试图通过添加$scope.section.value=response.data[0].section_id,但它给了我错误。在这里,我的要求是section_id应该设置为下拉的值和各自的名称应该显示。请帮我解决这个问题

you can use like this

<select ng-model="ContentAdditionalInfoModel.AdditionalInfoId"  class="form-control" ng-required="true"
                                                ng-options="item.AdditionalInfoId as item.AdditionalInfoName for item in  AdditionalInfoList">
                                            <option value="" selected="selected">Select</option>
                                        </select>
here AdditionalInfoList come from your database