角度自定义选择元素 - 记住所选项目

时间:2016-05-23 13:32:00

标签: javascript angularjs

我已获得以下代码;

  <select class="pi-native-dropdown--native-dropdown" data-ng-model="country" data-ng-options="country.countryLegend for country in countries track by country.countryLegend" data-ng-change="setCountry(country);validatePostcode()">
 </select>
  <img class="pi-native-dropdown--flag" data-ng-src="{{country.flagImg}}" alt="">

它是一个带有ng-options的选择项。当用户进行选择时 - 图像会相应更新。这将设置与用户选择的国家/地区对应的正确图像源。

首次加载时,我正在加载默认国家/地区。我正在使用以下内容做的事情;

$scope.selectedItem = {"countryCode":"A","countryLegend":"Österreich","passportRequired":true,"dialingCode":"+43","flagImg":"/content/dam/global/flags/Austria.png"};

我想要实现的目标:

我希望选择字段记住用户选择,这样当用户回来时 - 选择字段将具有记住的选择以及正确的图像。

有什么想法吗?

你可以在这里找到一个codepen: http://codepen.io/AntonioVassilev/full/GZdRLq/

0 个答案:

没有答案
相关问题