Does anyone know if it is possible to open a select programmatically in angularjs. Ive tried
angular.element(el).trigger(\'focus\');
angular.element(el).trig
i had same problem and finally i'm create my own directive:
angular.module('openselect', [])
.directive('openselect', function () {
var showDropdown = function (element) {
var event;
event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
};
return {
restrict: 'A',
scope: {
'elemento': '@'
},
link: function (scope, elem, attrs, ctrl) {
elem.bind('click', function () {
var elemento = document.getElementById(scope.elemento);
showDropdown(elemento);
});
}
};
});
To use:
Indicanos tu país
Adds directive to any tag passing id of select (elemento) that you want to open.
You can see the very basic javscript code inside directive if you want to use in other context;
hope it helps ;D