0

this question may sound noob to geeks with ng-expert tag in their shirts.

I've been seeing some AngularJS-based sites that whenever I clicked a link, the URL changes but the browser does not load, it only loads dynamic content to their ng-view.

If current URL is http://www.sample.com/ and I clicked on Contact us link, the URL at my browser becomes http://www.sample.com/contact-us and so the page content changes like Ajax load but the browser does not load.

That thing is kind of new to me, can someone enlighten me about this? I've seen several tutorials but links are only hashtag-based (http://www.sample.com/#contactus) and not route based. I don't know what specific Angular concept it is so I don't know what to look for.

I'll greatly appreciate constructive solid answers. Thanks!

2
  • 2
    You can start by checking out the $location service, especially the part about "HTML5 mode". Do note that URL rewriting is required in the server-side to support this. Commented Oct 16, 2015 at 11:01
  • Thanks @NikosParaskevopoulos for that link reference. I have Laravel as back-end :) Commented Oct 16, 2015 at 11:12

2 Answers 2

2

You can do routing with angular js without hash tags, by setting

   // use the HTML5 History API    
   $locationProvider.html5Mode(true);

so your browser url becomes http://www.sample.com/contact-us not http://www.sample.com/#contact-us

here is the complete tutorial blog, https://scotch.io/quick-tips/pretty-urls-in-angularjs-removing-the-hashtag

Sign up to request clarification or add additional context in comments.

Comments

1

You can change pages dynamically by changing the HTML on the main site or by $routeprovider

URL rewriting has to be supported by the server the site is hosted on. For this, look at: $location

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.