Angular.dart Disable Routing?

2019-07-11 07:52发布

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.

2条回答
疯言疯语
2楼-- · 2019-07-11 08:27

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

查看更多
小情绪 Triste *
3楼-- · 2019-07-11 08:29

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').

查看更多
登录 后发表回答