Why do you use the "raw" select2 jQuery plugin? There is an angular wrapper for it in angular-ui: https://github.com/angular-ui/ui-select2 It takes care of exactly that problem: Syncing angular mechanisms and the jQuery based select2 code.
The angular way would be not to pass the default value to your directive, but to init the model to the default value, watch the "ngModel" and set the value to the jQuery plugin whenever it changes. Also you would have to watch the collection used in "ng-repeat" and also update the value when it changes. This is exactly what angular-ui-select2 does. On Friday, June 6, 2014 7:29:12 PM UTC+2, Jay wrote: > > Having trouble in setting up the default value for the drop down when > AngularJS/ng-repeat/custom directive + Select2 JS is used. > > 1. I avoided using ng-options as the directive priority is 0. > 2. I tried setting the priority for the custom directive 'select2Directive' > to a number less than 1000, but still no luck. > > Plunker @ http://plnkr.co/edit/Csy5FqDSQbErTm2fNPac. Appreciate any help. > Thanks. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
