Using the Angular material library directive md-select
, I have implemented a feature to display country codes to users. When a country is selected, I want to show only the country's dialing code in the select box.
For example, if the user selects India (+91)
, the select box should display +91
as the text. The code I am currently using is:
<md-select ng-model="ctrl.selectedCountry" ng-model-options="{trackBy: '$value.code && $value.name && $value.prefix'}">
<md-option ng-repeat="country in ctrl.countries" ng-value="{{ country }}" >
{{ country.name }} ({{ country.prefix }})
</md-option>
</md-select>
I am struggling to find a way to display only the dialing code in the select box without changing the ng-model binding. Is there a way to specify a display text template based on the selected value?