ruhley / angular-color-picker

Vanilla AngularJS Color Picker Directive with no requirement on jQuery
http://ruhley.github.io/angular-color-picker/
MIT License
166 stars 79 forks source link

Need help with onChange #86

Closed tristar500 closed 8 years ago

tristar500 commented 8 years ago

I must be misunderstanding the docs. How do I set an onChange handler?

If I set it up like this, the color picker works as expected except that onColorChange never is fired.

HTML

<color-picker 
ng-model="item.color"
options="colorOptions"
color-picker-on-change="onColorChange($event, color)"
></color-picker>

Angular

    $scope.colorOptions = {
        format: 'hex',
        alpha: false,
        swatch: true,
        swatchBootstrap: true,
        swatchOnly: true
    };

    $scope.onColorChange=function($event, color){
            alert.log('onColorChange');
    };

If I set it up like this, color-picker breaks completely (the color picker box always displays in the last item of the list.

HTML

<color-picker 
 ng-model="item.color"
 options="colorOptions"
 api="api"
 ></color-picker>

Angular

$scope.api = {
    onChange: function($event, color) {
        alert.log('onColorChange API')
    }

Thank you!

ruhley commented 8 years ago

I forgot to update the documentation on the website, so maybe that's where the confusion is coming from. Using the api is the correct way.

It seems like you are having the same problem as #85. I will close this ticket as a duplicate and you can follow the conversation on the other ticket. If you feel that it is a separate issue then please re-open it.