1

I'm trying to use AngularJS $location to set the browser's url, like this:

$location.path("/post").search({
    id: post.id
});

but whenever I do the url gets set like http://localhost:5000/#!/post?id=0 instead of http://localhost:5000/post?id=0

Is there any reason the #!/ shows up?

2
  • did not my answer work Commented Sep 9, 2018 at 4:41
  • Your answer was helpful but only removed the ! from the url so it would read /#/post which wasn't what I was looking for. Commented Sep 10, 2018 at 1:27

2 Answers 2

2

In app config you should use

$locationProvider.html5Mode(true)
Sign up to request clarification or add additional context in comments.

Comments

1

If you want to remove this prefix, add this code to your config:

appModule.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('');
}]);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.