ui-select2 icon indicating copy to clipboard operation
ui-select2 copied to clipboard

reset selection

Open yingban opened this issue 11 years ago • 2 comments
trafficstars

Hi,

is there anyone who know how to reset a selection using the directive ?

With select2 non-angular lib, we just have to use : $(el).select2("val", "");

Thanks !

yingban avatar Aug 21 '14 13:08 yingban

use this code in uiSelect2 directive in compile function block after return function (scope, elm, attrs, controller) {

scope.$watch(attrs['ngModel'], function (v) {
                    if (v === '' || v===null || v===undefined) {
                        var select=elm.parent().find('.select2-selection__rendered');
                        if(select[0]){
                            select[0].innerHTML='<span class="select2-selection__placeholder">'+attrs['placeholder']+'</span>'
                        }
                    }
                });

...

noavaran-sharif avatar Jan 09 '18 11:01 noavaran-sharif

use this code in uiSelect2 directive in compile function block after return function (scope, elm, attrs, controller) {

scope.$watch(attrs['ngModel'], function (v) {
                    if (v === '' || v===null || v===undefined) {
                        var select=elm.parent().find('.select2-selection__rendered');
                        if(select[0]){
                            select[0].innerHTML='<span class="select2-selection__placeholder">'+attrs['placeholder']+'</span>'
                        }
                    }
                });

...

thanks

snnucr avatar Apr 08 '20 20:04 snnucr