如何在angularjs中更改ng-click到ng-touch

时间:2017-11-10 15:13:37

标签: javascript angularjs

我有申请,我已经写了一个小工具输入用户密码。在基于android的设备中使用ng-click似乎非常慢。我想将这些ng-click调用更改为ng-touch以测试按键按钮事件。这是我的代码:

(function(){
    var numpad = function($log) {
        return {
            restrict: 'E',
            templateUrl: 'partials/paddword.html',
            require: 'ngModel',
            link: function(scope, elem, attrs, ngModel) {

                scope.number = ngModel;

                scope.buttonPress = function(number) {
                    var value = scope.number.$viewValue || '';
                    scope.number.$setViewValue(value + number);
                };

                scope.remove = function() {
                    var value = scope.number.$viewValue || '';
                    if (value.length > 0) {
                        scope.number.$setViewValue(value.substring(0, value.length - 1));
                    }
                };

            }
        };
    };
    try {
        angular.module('myApplication').directive('numpad', numpad);

})();

和html看起来像这样:

<div class="numpad" id="numpad" align="center">
    <div>
        <kbd data-ng-click="buttonPress(A)">A<div class="background">&nbsp;</div></kbd><kbd data-ng-click="buttonPress(B)">B</kbd>
    </div>
<div>
 <kbd data-ng-click="remove()">Delete</kbd> </div>

有人可以告诉我如何在此指令中使用ng-touch进行buttonPress和删除功能吗?

0 个答案:

没有答案