带有 IOS 8.3 的 Safari 上的 Angular ng-click 问题 [英] Angular ng-click issues on Safari with IOS 8.3

查看:21
本文介绍了带有 IOS 8.3 的 Safari 上的 Angular ng-click 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个奇怪的问题,这是一些难以生成和探索的问题.

This is a weird issue, that is some what hard to generate and explore.

在使用 Angular 构建网络应用程序时,我的老板发现应用程序上所有使用 ng-click 指令的按钮都不起作用.

While building a web-app using Angular, my boss found that all the buttons on the app that are using ng-click directive are not working.

现在,这个问题只发生在iphone 6 with IOS 8.3 and using the safari browser.

Now, this issue only happens on iphone 6 with IOS 8.3 and using the safari browser.

我可以说,当在 iPhone5(所有版本)、iPhone 6(IOS 9)、Safari for windows 和所有其他浏览器(移动和桌面)上进行测试时,ng-click 就像魅力.

I can say that when was tested on iPhone5 (All versions), iPhone 6 (IOS 9), Safari for windows and all other browsers (Mobile and desktop), ng-click works like a charm.

应用正在使用 Angular 1.4.3 构建.

The app is being build using Angular 1.4.3.

这是按钮的代码,如你所见,没什么特别的:

This is the code for the button, as you can see, nothing special about it:

<button class="btn calculate-button" ng-click="onCalculate()">Calculate</button>

在控制器中:

$scope.onCalculate = function () {
     //Do something... And then:
     $state.go('someplace');
};



我尝试了这里建议的许多更改,包括 ng-touchng-bind,构建我自己的点击指令如下:



I tried many changes that were suggested here, including ng-touch, ng-bind, building my own click directive as follows:

.directive('basicClick', function($parse, $rootScope) {
    return {
        compile: function(elem, attr) {
            var fn = $parse(attr.basicClick);
            return function(scope, elem) {
                elem.on('click', function(e) {
                    fn(scope, {$event: e});
                    scope.$apply();
                });
            };
        }
    };
});

无法为问题找到任何合适的解决方案.

Couldn't find any proper solution for the problem.

谢谢.

推荐答案

我最后修好了.

问题出在函数的 //Do something... 然后: 部分.在此过程中的某个时刻,该函数会将一些数据保存到浏览器本地存储中.

The problem was in the //Do something... And then: part of the function. At some point along the way, that function saves some data to the browser local storage.

我的老板在 safari 上使用隐私浏览,显然在 safari 上使用隐私浏览时,浏览器不会将数据保存在本地存储上,并且会引发异常并杀死代码.

My boss was using private browsing on safari, and apparently when using private browsing on safari, the browser wont save and data on the local storage and it throws an exception and kills the code.

好吧,谢谢.

这篇关于带有 IOS 8.3 的 Safari 上的 Angular ng-click 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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