AngularJs中数据库的下拉绑定

时间:2016-06-20 12:31:51

标签: angularjs

我正在尝试将值绑定到“编辑”按钮上的字段。以前一切都工作正常,但突然下拉(性别)控制没有约束力。这是代码 - HTML UI -

$scope.EditEmployee = function (EID) {
        for (i in $scope.employees) {
            if ($scope.employees[i].EmpId == EID) {
                $scope.newemployee = {
                    EmpId: $scope.employees[i].EmpId,
                    Name: $scope.employees[i].Name,
                    Age: $scope.employees[i].Age,
                    Gender: $scope.employees[i].Gender,
                    City: $scope.employees[i].City
                };
            }
        }
    };

这是控制器将值绑定到控件 -

{{1}}

文本字段值正在绑定,但下拉列表显示空白

2 个答案:

答案 0 :(得分:0)

尝试更改

data-ng-model="newemployee.Gender"

ng-model="newemployee.Gender"

参考:here

此致

答案 1 :(得分:0)

试试这个..

in dropdown use -  ng-model="newemployee.Gender"

in option use   -   <option ng-model="newemployee.Gender">Male</option>
                    <option ng-model="newemployee.Gender">Female</option>