Is it possible to have traditional anchor links in Angular.js applications

Angular.js create URLs such as:

http://cooldomain.com{000/#/search

http://cooldomain.com{000/#/docs

In my docs document, I would like to have one long page with <a name="sdsds"> sections and a traditional content table with anchor links so that the user can jump up and down the page

It’s clear that a lot of invalid URLs will be created in the table of contents, such as http: //cooldomain.comhaps000/#/docs#coolAPIFunction , which, of course, will not work because of the double hash

So, is it possible to use anchor links in Angular.js applications with routes?

+6
source share
1 answer

You can enable html5 pushstate and get rid of # in your routes. You can do this by adding this to your .config

$ locationProvider.html5Mode (true);

However, keep in mind that now there will be no difference between Angular routes versus server requests. You will need to configure your server to deliver the corresponding static html file (e.g. index.html) for this URL.

+1
source

Source: https://habr.com/ru/post/957192/


All Articles