1

I've got this in a first controller : (executed on ng-mouseover)

$scope.overMenu = function() {
    $rootScope.$broadcast('overMenu');
    console.log('overMenu');
};

And this in a second one :

$scope.$on('overMenu', $scope.overMenu());
$scope.overMenu = function()
{
    console.log('on overMenu');
    //gridLayoutPlugin.updateGridLayout();
};

But my event is fired or catched only once and i don't understand why...

2 Answers 2

1

Solved !

I started over everything and putting my $scope.$on at the end of my controller, i don't remember but maybe i declared it before the function i wanted to call...

Sign up to request clarification or add additional context in comments.

Comments

0

Event handler should be a function reference:

$scope.$on('overMenu', $scope.overMenu);

When you put parentheses after function name you immediately invoke it. What you want to do is to provide a reference to a function to be called on once event occures.

1 Comment

hi, even when i try this : $scope.$on('overMenu', console.log('on overMenu')); it still works only once.

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.