0
使用角度和角度可调整我有一个下拉菜单,其中有许多选项可以在'amenities'数组中选择。显示之前在下拉菜单中选择的项目
一旦我从下拉列表中选择并保存它们,我想让用户可以回到页面并编辑以前选择的项目。
HTML:
<select multiple class="w-select am-dropdown" size="12" data-ng-model="Amenities"
data-ng-options="amenity.amenity for amenity in amenities" required=""></select>
JS:
$scope.amenities = [{amenity: coffee}, {amenity: beer}, {amenity: parking}];
$scope.Amenities = [];
$scope.selectedAmenities = [coffee, beer];//these are amenities saved in the
database that I want to be able to show as selected using the editable form
感谢您的回答。它像一个魅力。我不完全理解它;你摆脱了Amenities阵列,但你的解决方案并不需要它。在选择一件商品之前,事情有点奇怪,但它符合规范。谢谢。 – rashadb
欢迎您! –