To enhance the functionality of this directive, consider configuring it to listen for custom events that can be specified for each dropdown. For more information on how this can be implemented, refer to this explanation on Extending Angular Directives.
module.directive('chosen', function(){
return {
restrict:"A",
link: function($scope,$element,$attrs){
var event = $attrs.openOn;
$scope.$on(event,function(){
$element.trigger("chosen:open");
});
}
}
});
<button ng-click="show('event:a')">open</button>
<select chosen open-on="event:a">
$scope.show = function(event) {
$scope.$broadcast(event);
};
Explore a working example at http://jsfiddle.net/QbRAY/1/