buberdds / angular-bootstrap-colorpicker

Native AngularJS colorpicker directive. No dependency on jQuery or jQuery plugin is required.
MIT License
419 stars 226 forks source link

colorpicker-closed not fired #152

Open Lulunx opened 7 years ago

Lulunx commented 7 years ago

Hi, ( Sorry my english could be bad )

I'm using the colorpicker for a personnal developement, and I've actually a problem.

I want to send a request in a API when the user close the colorpicker ( I don't want to send it when the color change for don't flood the server ).

For that, I used the colorpicker-closed attribute like that

<button class="ui basic green fluid button" colorpicker type="button" colorpicker-size="200" colorpicker-closed="switchColor()" colorpicker-position="top" ng-model="color.color">Couleur</button>

The function switchColor(), is actually doing only a console.log() ( For debug ! )

$scope.switchColor=function(){ console.log('Test') }

But the close event is never triggered. If someone could help me ?

Thanks Lucas

llevii commented 7 years ago

Hi,

I ran into the same problem, but found the solution. I think in your controller you should use this instead:

$scope.$on('colorpicker-closed', function(event, colorObject){
        console.log(event, colorObject);
   });

And colorpicker-closed="switchColor()" is unnecessary in your html code.

Cheers,

Levi

Lulunx commented 7 years ago

Hi,

Thanks for your help, it worked. I didn't know about .$on ( it was maybe my problem ! )

Lucas