Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs clear history when view loaded

Tags:

angularjs

Is there a way of clearing the history that Angular JS stores when a particular view is loaded through the routeProvider?

I am creating a public installation using angular and the history is going to build up a lot so I want to clear it when the home page is loaded.

like image 754
user2424495 Avatar asked Sep 28 '13 16:09

user2424495


Video Answer


1 Answers

in your Controller inject $scope and $location.

$scope.$on('$viewContentLoaded', function(){
  //view loaded do some stuff.
    $location.replace(); //clear last history route
});
like image 101
schwertfisch Avatar answered Sep 29 '22 18:09

schwertfisch