1
我真的很陌生,並試圖在我的應用程序註冊頁面中爲各個國家實施下拉菜單,我可以在響應中顯示下拉數據中的數據,但我不是能夠在選擇物品時獲得其關鍵價值。從ng選項獲取密鑰angularjs
下面是對此我在我的下拉顯示我的JSON響應:
{
AD: "Andorra",
AE: "United Arab Emirates",
AF: "Afghanistan",
AG: "Antigua and Barbuda",
AI: "Anguilla",
AL: "Albania",
AM: "Armenia",
AN: "Netherlands Antilles",
AO: "Angola",
AQ: "Antarctica",
AR: "Argentina"
}
在我的API響應現在的儲蓄,如:
$scope.results = response.data;
而且這裏是我的顯示方式它在我的下拉內:
<select class="input-select" >
<option value="" disabled selected hidden>Country</option>
<option ng-change="selectedCountry()" ng-repeat="(key, value) in results" ng-model="country" value="{{key}}">{{value}}</option>
</select>
我只是試圖通過全光照讓用戶所選國家的關鍵g功能
ng-change="selectedCountry()"
在我的Html。但是這個函數沒有被調用。
任何幫助將不勝感激 謝謝。
這位朋友你好,感謝您的回覆,但我仍沒有得到所選國家的關鍵,我使用$ scope.country到得到鑰匙。 – sid
嘗試在你的控制器中使用對象,例如:'$ scope.user = {}',並在HTML中綁定到這個對象'ng-model =「user.country」'。 – dfsq
謝謝兄弟..... – sid