Angular.dart Disable Routing?

ε祈祈猫儿з 提交于 2020-02-24 11:45:51

问题


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.


回答1:


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




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



来源:https://stackoverflow.com/questions/22357759/angular-dart-disable-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!