0

I have a jquery colorPicker component. in myApp.js, I use that snippet:

    myApp.controller('chatController', function ($scope) {
    $scope.texts = [];      
    $scope.color = "#00FF00";
    $scope.test = "before";

$('button#color').simpleColorPicker({ onChangeColor: function(color) {
        console.log(color);
        $scope.color = "#FF0000";
        $scope.test = "after";
     } });

I have a {{color}} and {{test}} in my view.

Problem is: when colorPicker triggers changed, this is not reflected ! Instead I need to refresh some other data bindings and then {{test}} and {{color}} change.

What is wrong ?

2
  • You need a $scope.apply(function(){$scope.color = "#FF0000"; $scope.test = "after";}) inside onchange color Commented Aug 13, 2014 at 14:23
  • It is angular basics.. You need to manually force digest cycle when out of angular... Commented Aug 13, 2014 at 14:30

1 Answer 1

1
$scope.test = "after";
$scope.$apply(); // tells Angular to update all the bindings
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.