How to force Angular to send request to server on HTML5 mode?
From the Docs:
In cases like the following, links are not rewritten; instead, the browser will perform a full page reload to the original link.
Links that contain target element. Example:
<a href="/ext/link?a=b" target="_self">link</a>
Absolute links that go to a different domain. Example:
<a href="http://angularjs.org/">link</a>
Links starting with '/' that lead to a different base path when base is defined. Example:
<a href="/not-my-base/link">link</a>
So, as a simplest solution, just add target="_self"
to your link.
If you'd rather change the route configuration in one place instead of changing all link elements, you can do this:
$routeProvider.when('/externalpath', { resolve: { redirect: ['$location', function($location) { window.location.replace($location.absUrl()); }]}});
This basically invokes the inlined function whenever a link to that route is hit, and the function just redirects the browser to the target location (outside of angular). The 'resolve' configuration is processed regardless of whether a template or controller is configured for the route, and the 'redirect' name is basically just a dummy name - the important thing is that the function gets executed to get its value (which is unused in this case).
This is also useful when e.g. you have a /signout url that needs to reach the server. You can also use an otherwise() configuration instead of when() if you want all non-configured paths to be handled by the server.