md-select option to specify display text template after selection.
I have a simple use case where I wish to show a bunch of country names with their dialing codes to my users. On selecting a country i want the selected option to only show the dialing code. I don't see any way to specify a custom template for the select box based on the selected option.
ex. if user selects option India (+91) then the select box display text should change to +91 while the model binding with the country object is maintained.
Here is my code snippet:
<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>
Is there any way to achieve this?
Was curious of the progress on this feature...working on a piece that could benefit from this.
Well, I also need this feature, and I implemented this in an awkward way now...
Something like:
<md-select ng-model="ctrl.selectedCountry">
<md-option ng-repeat="country in ctrl.countries" ng-value= "{{ country }}" >
{{ country.name }}<span class="prefix"> ({{ country.prefix }})</span>
</md-option>
</md-select>
And CSS:
md-option .prefix {
display: none;
}