0

Basically I'm asking this gentleman's question: How to disable static url in angular ui-router?

My DOM structure looks like this:

<div ui-view>
  <a href="/link-to-non-angular-page">Click Me</a>
</div>

I want people to be able to click that "Click Me" link and have it force the page to take you to that page as if Angular and UI Router didn't exist, as a standard HTTP page request with everything reloading.

Is that doable?

Community
  • 1
  • 1
Martyn Chamberlin
  • 1,277
  • 14
  • 17
  • can't you perform e.preventDefault() and change window.location to the url you need ? – DinoMyte Dec 30 '15 at 01:07
  • doable yes... just capture it on the server but this requires us to know the server implementation – Daemedeor Dec 30 '15 at 01:11
  • @DinoMyte I could definitely do that but if the user CTRL + clicked the link (or CMD + clicked on a Macintosh) then they'd expect the thing to open in a new tab, and unfortunately you can't reliably do that in a web browser with just JavaScript. Ideally the solution would simply allow the native functionality to occur without any JavaScrip hacks. – Martyn Chamberlin Dec 30 '15 at 01:25
  • @Daemedeor Sorry, I'm afraid that's not making any sense. :) This is strictly a client-side question here. – Martyn Chamberlin Dec 30 '15 at 01:25
  • @MartynChamberlin "as if angular and ui router didn't exist" suggests to me that you have a backend to this system other than front-side code. you need to capture it as normal on your backend code instead of doing a catch all.. i mean if you don't catch it in angular where else do you route to? – Daemedeor Dec 30 '15 at 01:35
  • how can it be strictly client-side if you're not using angular? – Daemedeor Dec 30 '15 at 01:51
  • @Daemedeor Sorry for the miscommunication. I'll try to re-explain. By default, if you click a link on a standard HTML page, you generate a full HTTP request of that page. In ui-router, when you click a link all you're doing is generating a view and controller. I'd like to have a link inside ui-router that is treated like a normal link, i.e., the browser loads the linked page as a standard page request. How the server chooses to handle that HTTP request once it's been generated is outside the scope of this question. I just want to be able to generate the request in the first place! Make sense? – Martyn Chamberlin Dec 30 '15 at 03:53
  • 1
    might wanna go here then: http://stackoverflow.com/questions/20980201/angular-ui-router-link-out-of-app-but-in-the-same-domain – Daemedeor Dec 30 '15 at 03:58
  • @Daemedeor That was exactly what I was looking for. Thanks so much!! – Martyn Chamberlin Dec 30 '15 at 04:14

1 Answers1

1

So @Daemedeor answered my question in above comments. The solution is to add this to the link:

target="_self"

So the above markup would turn into:

<div ui-view>
  <a href="/link-to-non-angular-page">Click Me</a>
</div>

Thanks!

Martyn Chamberlin
  • 1,277
  • 14
  • 17