1

I need to use jQuery's .unload() inside AngularJS:

My Controller

$(window).unload(someHandler());

var someHandler = function() {
  console.log('handled!');
};

My View

<section ng-controller="UnloadController">
</section>

The event is fired upon unload, but for some reason it is fired on load too. I am guessing this Angular messing something up?

1 Answer 1

2

You are invoking it with the () when you pass the function in to the listener.

Try passing it in without invoking it.

$(window).unload(someHandler);
Sign up to request clarification or add additional context in comments.

1 Comment

I'm an idiot. Thank you! I'm glad that is all it was.

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.