Vlad V Vlad V - 5 months ago 35x
AngularJS Question

angular.js link behaviour - disable deep linking for specific URLs

I have a working Angular.js app with HTML5 mode enabled.


What I want to achieve is to get some URLs or
tags to do the normal browsing behaviour instead of changing the URL in the address bar using HTML5 history API and handling it using Angular controllers.

I have this links:

<a href='/auth/facebook'>Sign in with Facebook</a>
<a href='/auth/twitter'>Sign in with Twitter</a>
<a href='/auth/...'>Sign in with ...</a>

And I want the browser to redirect the user to
so the user will be then redirected to an authentication service.

Is there any way I can do this?

Nik Nik

Adding target="_self" works in Angular 1.0.1:

<a target="_self" href='/auth/facebook'>Sign in with Facebook</a>

This feature is documented (https://docs.angularjs.org/guide/$location - search for '_self')

If you're curious, look at the angular source (line 5365 @ v1.0.1). The click hijacking only happens if !elm.attr('target') is true.