2

I'm only using Angular.dart on part of my page...The rest contains another Dart app (compiled down to JS...everything is in JS from Dart) and some other HTML, etc. Essentially my Angular.dart app is just a component within the page.

However, now all links on the page seem to want to go through Angular.dart routing. I don't even need routing (though have a few defined) technically.

Is there a way to disable the routing altogether? So that when clicking on <a href="/page2">Another page</a> actually works like normal, changing the URL in the address bar? Right now it's just going to # and all my links are disabled. I wasn't even using ng-click or anything like that either.

How can I make Angular.dart just leave those links alone? Thanks.

Tom
  • 3,507
  • 1
  • 29
  • 29

2 Answers2

2

You can reduce the scope of Angular in your page by putting ng-app on the element where Angular.dart is used. Thus, the links outside of this element will work.

<a href="direct-link">link</a>
<div ng-app>
  <a href="link-catch-by-angular">link</a>
</div>

For links inside Angular part there's perhaps a native way to handle them but you can add a directive that handle onClick on the element and performs window.location.assign('link').

Alexandre Ardhuin
  • 71,959
  • 15
  • 151
  • 132
  • Yea, that's what I had at first, but then I had to move it to `` because it had issues with updating the DOM for other things (I had a service that loaded JSON and updated a table in a modal). – Tom Mar 12 '14 at 17:04
  • Can I automatically handle all clicks from my Angular.dart app globally from the Angular.dart code? (so I don't have to update all the HTML) I really don't think I'll be using Anuglar.dart routing at all... – Tom Mar 12 '14 at 17:24
  • I was able to move `ng-app` to another element other than `` fortunately. This solves my issues for now though I wonder if there is a better solution...Perhaps something within Angular.dart that catches everything and then decides to pass it along to the browser like normal or prevent the normal behavior and route via Angular. – Tom Mar 12 '14 at 21:21
2

Since route_hierarchical-0.4.19 you can simply add a target="_self" to your <a href="...."> to avoid angular router.

Alexandre Ardhuin
  • 71,959
  • 15
  • 151
  • 132