Using setInterval in AngularJS: the proper way

I've been working on the autoSave feature of my app and I was frustrated of the way setInterval work in AngularJS. When the controller is initialized, the setInterval starts to run and even when the route (state, if you are using ui-router) changes with the other controller, the interval is still running which is a stress for the CPU. So this time I tried to figure that out and found that the solution was there in the AngularJS official document.

var stopAutoSave;
stopAutoSave = $interval(function() {
}, 10000);
$scope.stopFight = function() {
if (angular.isDefined(stopAutoSave)) {
stopAutoSave = undefined;
$scope.$on(‘$destroy’, function() {
// Make sure that the interval is destroyed too