The following code was recently merged into the master branch.
//unbind the event when scope destroyed
$scope.$on("$destroy", function() {
angular.element(window).off();
});
Calling off() without any event types on the window element will de-register ALL event listeners on the window object. This has the side-effect of removing the listeners that ngRoute uses to listen for page change events (ie. those as generated by the browser Back/Forward buttons). This breaks the usage of back/forward buttons in Angular.
This changes this deregistration to the below so that only 'resize' listeners are removed.
//unbind the event when scope destroyed
$scope.$on("$destroy", function() {
angular.element(window).off('resize');
});
This pull request also includes a commit that makes some style consistency changes. Previously, there was inconsistent whitespace and a couple missing semicolons. If you would prefer to keep the styling as-is, I can remove that commit.
The following code was recently merged into the master branch.
Calling
off()
without any event types on the window element will de-register ALL event listeners on thewindow
object. This has the side-effect of removing the listeners that ngRoute uses to listen for page change events (ie. those as generated by the browser Back/Forward buttons). This breaks the usage of back/forward buttons in Angular.This changes this deregistration to the below so that only 'resize' listeners are removed.
This pull request also includes a commit that makes some style consistency changes. Previously, there was inconsistent whitespace and a couple missing semicolons. If you would prefer to keep the styling as-is, I can remove that commit.