Setting initial values of Angular-UI Select2 multiple directive

前端 未结 2 816
一生所求
一生所求 2021-02-05 06:39

I have a select2 directive for a multiple select of countries with a custom query to grab the data:

// Directive


        
2条回答
  •  再見小時候
    2021-02-05 06:57

    As requested by ProLoser here is a demo and github ticket.

    Demo: http://plnkr.co/edit/DgpGyegQxVm7zH1dZIJZ?p=preview

    GitHub Issue: https://github.com/angular-ui/angular-ui/issues/455

    Following ProLoser's advice I started using select2's initSelection function:

    initSelection : function (element, callback) {
      callback($(element).data('$ngModelController').$modelValue);
    },
    

    It does the trick but still feels like a workaround.

提交回复
热议问题