Can't navigate back to homepage when the user reload the page

I want the feature of ionic 2 which when a user reload a page will redirect to the rootPage. Any idea how can i do it to ionic 1 using angular 1.5 ? I tryied this code but doesn’t work.

var windowElement = angular.element(window);
windowElement.on(‘beforeunload’, function (event) {
windowElement.location.href = ‘/index.html’;
return false;