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
歡迎您! –