Question: Have links use AngularJS routing instead of MVC routing

Question

Have links use AngularJS routing instead of MVC routing

Answers 1
Added at 2016-12-31 01:12
Tags
Question

I have a SPA which uses an AngularJS front end and C# back end. The issue I'm having is when I navigate to the login page, it is using @Html.Partial("_LoginPartial"). The url then becomes .../Account/Login.

When I click on say the "About" tab, this uses an AngularJS route which in turn instead of routing me to the About Page, it tacks on the route to the end of the login route like so: .../Account/Login#/about and obviously doesn't route anywhere.

Would anyone know how I would resolve this? I have spent hours looking into this issue and haven't really found anything as of yet.

Answers to

Have links use AngularJS routing instead of MVC routing

nr: #1 dodano: 2016-12-31 01:12

What you need to do is setup the $location service to use HTML5 mode, which uses the HTML5 History API to modify the URL on the fly.

See:

Source Show
◀ Wstecz