【发布时间】:2018-01-26 05:55:14
【问题描述】:
我有一个连接到数据库的简单 AngularJS 表单。
表单在 HTML 表格中显示姓名和出生国家/地区列表:
<table class="table table-bordered" style="max-width: 100%;" id="myAreas">
<tr ng-repeat="name in Names">
<td>{{name.FullName}}</td>
<td>
<select ng-model="selectedCountryForEdit" ng-show="editMode">
<option ng-repeat="z in countryList" value="{{z.CountryCode}}">{{z.CountryName}}</option>
</select>
<span style="display: block;" ng-show="!editMode">{{areaItem.Countries}}</span>
</td>
<td><a href="" ng-click="editMode = !editMode"><i class="fa fa-pencil" aria-hidden="true"></i></a></td>
</tr>
</table>
表格使用以下 JS/Angular 代码:
$http.get('/Home/GetNames')
.then(function (response) {
$scope.Names = response.data;
})
.catch(function (e) {
console.log("error", e);
throw e;
})
.finally(function () {
console.log("This finally block");
});
JS/Angular 正在 MVC 上调用一个方法来列出数据库中的数据。
我不想包含 MVC 代码,因为它工作正常,而我的问题依赖于其他东西:
如果查看 html 表格,每行都有一个铅笔图标,可以让我显示下拉菜单而不是国家/地区。
我正在做的是用数据库中的国家列表填充下拉菜单,我希望下拉菜单显示所选行/名称的相同国家/地区。
我搜索了很多,但找不到解决此问题的方法。我对 Angular 和 JS 很陌生,希望您能就此提出建议。
【问题讨论】:
标签: javascript angularjs html drop-down-menu