How Angular JS Deep Linking Works

Using Angular 1.4

When I try to enter the following url in the url bar,

https://application.com/movies/index.html?cd=1501739429812#/Movies/Action/2

      

the first request sent to the server contains the url (Chrome's Networks tab)

https://application.com/movies/index.html?cd=1501739429812

      

but the application loads the requested page.

How to get through #/Movies/Action/2

to load the correct route.

First request sent to server from browser:

Request URL: https://application.com/movies/index.html?cd=1501739429812
Request Method:GET
Status Code:200 OK
Referrer Policy:no-referrer-when-downgrade
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive

      

hashbang content is not passed.

enter image description here

Any help would be greatly appreciated. Thank you in advance.

+3


source to share


1 answer


You will find the answer in the AngularJS routes config. The hash content is never passed to the server and it is for this reason that many developers run into problems when they enable HTML5 mode in AngularJS routing.

If you notice the response of the returned content, you will notice that it is lacking in detail /Movies/Action/2

.



But it has a script to load AngularJS and its routes. So, once your page is loaded in the browser, AngularJS and the routing engine come in. They observe your browser url hash and act accordingly (load /Movies/Action/2

in your case).

+1


source







All Articles