如何快速点击+ AngularJS for iPad

And*_*own 4 ipad angularjs

使用AngularJS在iPad上单击ng-click时会出现延迟我有需要编写的generate指令

my_app.directive 'touch', ->
  (scope, e, attr) ->
    e.fastClick (e) ->
      scope.$apply attr.fastClick
Run Code Online (Sandbox Code Playgroud)

但它不知道fastClick是什么,即使我已将它包含在我的应用程序中.我认为它需要创建为服务,然后注入我的指令,但如何?

nyc*_*nik 15

万一其他人发现这个,谁不使用咖啡脚本,这里是转换

 app.directive("ngTap", function() {
  return function($scope, $element, $attributes) {
    var tapped;
    tapped = false;
    $element.bind("click", function() {
      if (!tapped) {
        return $scope.$apply($attributes["ngTap"]);
      }
    });
    $element.bind("touchstart", function(event) {
      return tapped = true;
    });
    $element.bind("touchmove", function(event) {
      tapped = false;
      return event.stopImmediatePropagation();
    });
    return $element.bind("touchend", function() {
      if (tapped) {
        return $scope.$apply($attributes["ngTap"]);
      }
    });
  };
});
Run Code Online (Sandbox Code Playgroud)

这是gfTop,因为样本是"好电影"的应用程序.随意将其更改为您喜欢的任何内容.

另请注意,您必须将所有"ng-click"更改为"gfTap".

更新:处理点击和点击事件.