Reputation: 915
I am new to AngularJS and need to ask one basic question. I have a select box in which the user can select a country from the country list. Once a country is selected, the value is the country code. I need to change this and update both the country name and country code when selecting any country.
Here is the current code:
<select ng-model="model.country_code" ng-options="c.code as c.name for c in countries">
My requirement is to set one more value called country_name in model once user selects some value in select box.
Basically I need to update two model entries on a single selection.
Upvotes: 2
Views: 101
Reputation: 41447
Just assign the whole object to the ng-model
, and filter it:
<select ng-model="model.country_code" ng-options="c as c.name for c in countries">
Upvotes: 1