使用Angular如何在编辑模式下绑定下拉控件?

时间:2016-11-19 05:58:54

标签: angularjs

当我点击编辑按钮时,下拉列表不会出现,但是当我在Insepect模式下跟踪它时,它会显示值 的 HTML

  <table>
    <tr>
    <td>
     <input type="button" class="btn btn-sm btn-primary" value="Edit" ng-click="Edit(Ass)" />

    </td>
    </tr>
    </table>
<div>        
    <b>Country</>
     <div>
        <select name="cntr" data-ng-show="Ass.CountryName" ng-options=" I.CountryID as I.CountryName for I in CountryList track by I.CountryID" ng-model=" CountryID" class="form-control" ng-change="GetStates()" ng-class="submitted?'ng-dirty':''" required>
     <option ng-repeat="ss in CountryList" value="ss" ng-selected="Ass.ss.CountryName">{{ss}}</option>
                                            </select>

                                             <span class="Error" ng-show="(f1.cntr.$dirty ||submitted) && f1.cntr.$error.required">Select Country</span>
                                        </div>
                                    </div>
                                </div>
</div>

Angular.Js

function CountryList() {
        var x = $Myservice.GetCountrys();
        x.then(function (d) {
            $scope.CountryList = d.data;
            //$scope.selectedItem = CountryList;
        })
    }

1 个答案:

答案 0 :(得分:0)

您还设置了data-ng-show="Ass.CountryName"。确保它可用,而不是null或undefined