This is what I did in my controller.
When I get the form data for modification, first I save its string representation in a variable scope as follows:
$scope.originalData = JSON.stringify($scope.data);
Then I create a state change listener:
var $locationChangeStartUnbind = $scope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) { if ($scope.originalData !== JSON.stringify($scope.data)) {
Then I clear the listener from the area of โโdestruction:
$scope.$on('$destroy', function () { window.onbeforeunload = null; $locationChangeStartUnbind(); });
Hope this helps.
manukyanv07 Apr 20 '15 at 16:58 2015-04-20 16:58
source share