Looking to prefilled a select tag used for country selection with options using a directive:
<select class="countryselect" required ng-model="cust.country"></select>
The custom directive I've created is as follows:
return {
restrict : "C",
link: function postLink(scope, iElement, iAttrs) {
var countries = [
["AND","AD - Andorra","AD"],
["UAE","AE - Vereinigte Arabische Emirate","AE"]
... //loop array and generate opt elements
iElement.context.appendChild(opt);
}
}
Although I am successfully adding additional options to the select, I am facing an issue with the ng-model binding. Even when cust.country has a value (e.g. "UAE"), the option is not selected.
Any suggestions on how to ensure that the select displays the value of cust.country? I suspect there might be a timing problem at play here.