选定项目显示在Edit Case Angular JS的下拉列表中

时间:2018-02-19 06:39:24

标签: angularjs drop-down-menu html-select dropdown

查看代码显示客户端下拉列表 -

<select ng-model="employee.DeptId" class="form-control ng-pristine ng-invalid ng-invalid-required" required="">
<option disabled="disabled" value="">---Please Select---</option>
 <option ng-repeat="Dep in ShowDep" value="{{Dep.Id}}">{{Dep.Name}}</option>
</select>

编辑案例中的角色代码----

$scope.EmployeeEdit = function (rowNumber) {
args = employeeArr[rowNumber];
$scope.employee.DeptId = args.DeptId;
 }

2 个答案:

答案 0 :(得分:6)

不清楚绑定数据的结构。 所以我在这里用自己的数据显示你的要求。我想你也可以在鳕鱼中做同样的事。

$scope.degrees = [
                   {"degree_code":"GB","degree_name":"Bachelor of Science"},
                   {"degree_code":"GR","degree_name":"Non Degree Undergraduate"}
                 ];
 $scope.selecteddegree = {degree_code:"GB"};

<!-- html -->
 <select name="degree" class="form-control" ng-model="selecteddegree" ng-options="degree.degree_name for degree in degrees track by degree.degree_code" >
           <option value=""> Select Degree </option>
 </select>

答案 1 :(得分:2)

在选项标签中使用ng-value而不是value。

<select ng-model="employee.DeptId" class="form-control ng-pristine ng-invalid ng-invalid-required" required="">
<option disabled="disabled" ng-value="">---Please Select---</option>
 <option ng-repeat="Dep in ShowDep" ng-value="{{Dep.Id}}">{{Dep.Name}}</option>
</select>