AngularJS - 使用ngTouch重定向与ngRoute不href和NG-点击属性工作 [英] AngularJS - using ngTouch redirection with ngRoute doesn't work with href and ng-click attribute

查看:157
本文介绍了AngularJS - 使用ngTouch重定向与ngRoute不href和NG-点击属性工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过与ngRoute应用程序导航。我使用类似链接:

I navigate through the app with ngRoute. I use links like:

<a href="#/page2" ng-click="showOffCanvas = false">Link</a>

由于我使用ngTouch导航无法在触摸设备上工作。我与Android手机和Chrome的设备模拟器尝试过。在桌面上的一切工作正常。

Since I use ngTouch the navigation doesn't work on touch devices. I tried it with an android phone and with chrome's device emulator. On the desktop everything works fine.

当我删除ngTouch这个问题消失。它也消失了,当我删除NG单击属性。

When I remove ngTouch this problem disappears. It also disappears when I remove the ng-click attribute.

链接到:

<a href="www.google.com" ng-click="showOffCanvas = false">google</a>

正在每个设备上。似乎只有与ngRoute路由停止工作,当我有ngTouch。

is working on every device. It seems that only the routing with ngRoute stops to work, when I include ngTouch.

什么是解决?

推荐答案

这是一个古老的错误,这是不是在此之前解决。
href和吴一起点击不`吨的工作。

It is an old bug, that wasn't fixed before this time. Href and ng-click doesn`t work together.

一个解决办法可能是使用空href和把导航
  逻辑到NG-单击使用$位置。

A workaround could be to use an empty href and put the navigation logic into ng-click using $location.

证明: https://github.com/angular/angular。 JS /问题/ 5307#issuecomment-30024683

在HTML:

<a href="" ng-click="showOffCanvas = false; goTo('#/page2')">Link</a>

在控制器:

$scope.goTo = function(refer){
    $location.path(refer)
};

这篇关于AngularJS - 使用ngTouch重定向与ngRoute不href和NG-点击属性工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆