gonewandering / angles

An angular.js wrapper for Chart.js
MIT License
632 stars 87 forks source link

Angular Routing Fix #40

Closed NateRedding closed 10 years ago

NateRedding commented 10 years ago

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.

NateRedding commented 10 years ago

Closing this PR since the newest version of Chart.js precludes the need for including responsive resizing as part of Angles.