在移动设备或平板电脑上点击点击 [英] ng-click on firing on mobile or tablet devices

查看:169
本文介绍了在移动设备或平板电脑上点击点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在页面加载中,我有一个控制器调用服务,然后将返回的数据绑定到一些$ scope.objects:

On page load i have a controller that calls a service and then binds the returned data to some $scope.objects:

app.controller("MainController", function($scope, $http, serviceGetData) {

    serviceGetData.getData(function(data) {
        $scope.LoginCount = data.LoginCount;
        $scope.ProductInfo = data.ProductInfo;
        $scope.ProfileInfo = data.ProfileInfo;

        // Delayed binding
        $scope.OrderHistory  = { History: [] };
    }

    $scope.populateModel = function(model, values) {
        var isArray = $.isArray(values);

        $.each(values, function(key, value) {

            if (isArray) {
                key = this.key;
               value = this.value;
            }

            if (model[key] !== value) {
                model[key] = value;
            }

        });
    };
}

在我的HTML中,我尝试绑定$ scope.OrderHistory:

And in my HTML, i try to bind $scope.OrderHistory by:

<h1><a href="#" ng-click="populateModel(OrderHistory  , { History: OrderEntries })" >View order details</a></h1>

在笔记本电脑/桌面上查看,但在平板电脑和移动设备上无法使用iphone / ipad

This is fine when viewing on laptops/desktops, but not working in tablet and mobile devices e.g. iphone/ipad

推荐答案

尝试添加ngTouch 。从文档中:


设计为使用的默认 ngClick 在触摸屏设备上。大多数移动浏览器在点击发布之前等待约300ms,然后再发送点击事件。此版本立即处理它们,然后阻止以下点击事件传播。

A more powerful replacement for the default ngClick designed to be used on touchscreen devices. Most mobile browsers wait about 300ms after a tap-and-release before sending the click event. This version handles them immediately, and then prevents the following click event from propagating.

需要 ngTouch 要安装的模块。

Requires the ngTouch module to be installed.

这篇关于在移动设备或平板电脑上点击点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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