leocaseiro / angular-chosen

AngularJS Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a AngularJS way
http://leocaseiro.github.io/angular-chosen/
MIT License
682 stars 248 forks source link

How to stopPropagation on click open select chosen ? #271

Closed tuananhzippy closed 4 years ago

tuananhzippy commented 4 years ago

Hello!

I'm having a problem on event listener of angular-chosen.

HTML Code:

<div ng-click="selectedLocation()"> <select chosen ng-model="location" ng-click="stopPropagation($event)" ng-options="location.id as location.name for location in locations"> <option value="">Location</option> </select> </div>

Javascript Code:

$scope.selectedLocation = function () { alert("Click Selected"); // show alert on click select chosen }

$scope.stopPropagation = function (event) { event.preventDefault(); //not working return event.stopPropagation(); //not working }

I tried other events but it didn't work: ng-focus ng-mousedown ng-mouseenter

Please help me solve this problem. Thank you!

VanTanev commented 4 years ago

What you're probably looking for is ng-change on <select> instead of that wrapping ng-click. Also, this is not a bug in angular-chosen. You should go to stack overflow for generic angular questions.