Navigate to URLs outside of the Angular application with target=”_self”

Today I brought in Angular’s routing to a view I was working on, clicked on a link which is on the same server but outside of the Angular application, and my browser’s URL updated, but the screen was just blank. Angular had hijacked the link and tried to route to the href itself.

I found the solution in the Angular Google Group.

<a href="/someUrl/inTheSameDomain" target="_self">
A link outside the Angular app
</a>

Adding target=”_self” to the link makes it so that Angular won’t use its own routing to try to navigate to that URL.

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Navigate to URLs outside of the Angular application with target=”_self”

  1. Z F says:

    I know this is an old post, but over a year later I came across this post looking for a solution to this issue. Another way to fix it is to limit the scope of your ng-app. Most examples put ng-app up on the body tag which causes everything in the body to become part of the angular app. If you have a standardized page wrapper and only want the angular app to inhabit a portion of the page move the ng-app attribute down to a div that surrounds only the portion of the page the app should affect. The HTML would basically look like this somewhere inside the body:

Comments are closed.