简体   繁体   English

Angular.dart禁用路由?

[英]Angular.dart Disable Routing?

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. 我只在页面的一部分上使用Angular.dart ...其余的包含另一个Dart应用程序(编译为JS ...所有内容都来自Dart的JS)和其他一些HTML,等等。从本质上讲,我的Angular.dart应用程序只是页面中的一个组件。

However, now all links on the page seem to want to go through Angular.dart routing. 但是,现在页面上的所有链接似乎都希望通过Angular.dart路由。 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? 这样,当单击<a href="/page2">Another page</a>实际上是否可以正常工作,请更改地址栏中的URL? 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. 我什至没有用ng-click或类似的东西。

How can I make Angular.dart just leave those links alone? 我怎样才能使Angular.dart仅仅保留那些链接? Thanks. 谢谢。

You can reduce the scope of Angular in your page by putting ng-app on the element where Angular.dart is used. 通过将ng-app放在使用Angular.dart的元素上,可以缩小页面中Angular的范围。 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') . 对于Angular部分内的链接,也许有一种本机处理方式,但是您可以添加一个指令 ,该指令处理元素上的onClick并执行window.location.assign('link')

route_hierarchical-0.4.19开始,您可以简单地在<a href="....">添加target="_self"以避免成角度的路由器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM