Skip to content

Instantly share code, notes, and snippets.

@tkssharma
Created June 23, 2016 08:32
Show Gist options
  • Save tkssharma/062cc426d61ec84a72a915493cacbb33 to your computer and use it in GitHub Desktop.
Save tkssharma/062cc426d61ec84a72a915493cacbb33 to your computer and use it in GitHub Desktop.
//be sure to inject $scope and $location somewhere before this
var changeLocation = function(url, force) {
//this will mark the URL change
$location.path(url); //use $location.path(url).replace() if you want to replace the location instead
$scope = $scope || angular.element(document).scope();
if(force || !$scope.$$phase) {
//this will kickstart angular if to notice the change
$scope.$apply();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment