190
rated 0 times
[
195]
[
5]
/ answers: 1 / hits: 34062
/ 11 Years ago, tue, august 27, 2013, 12:00:00
I have a select tag (to be used for country selection) which I want to prefill with options using a directive:
<select class=countryselect required ng-model=cust.country></select>
My directive goes like
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);
}
}
I am able to fill the select with additional options, but the ng-model binding does not work. Even if cust.country has a value (e.g. UAE), the option is not selected.
How to make the select display the value of cust.country? If think I have some timing problem here.
More From » angularjs