closure in JavaScript

How to disable browser back button AngularJs?

AngularJs provides a useful event called location Change Start. The examples for $rootScope and $scope level looks like,

Example1 for $scope level as below,

//How to disable browser back button angularjs?
//Added event listner for disabled back button.
$scope.$on('$locationChangeStart', function(evnt, next, current){            
    alert("Your, browsers back button is disabled!");

    //Prevent browser's back button default action.

Example2 for $rootScope level as below,

//Using $rootScope for event $locationChangeStart.['$rootScope', function ($rootScope) {
     $rootScope.$on('$locationChangeStart', function (event) {

I hope, It might help you! Thank you!


Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - and
My Books - Interview Questions and Answers Books- Get Your Book in 15+ Digital Stores Worldwide..

You Might Also Like Powered by Blogger.
ASK Questions