NG-重复角+触感键盘 [英] Ng-Repeat Angular + Touch Keyboard

查看:116
本文介绍了NG-重复角+触感键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个表,一些领域,以添加新行的选项。最后,我将打印所有领域。
我打算做的应用程序是触摸显示器,所以我做了一个新的键盘。
现在的问题是,如果我preSS这款键盘的一个按键,我可以读取corrispondent输入,但我不能JSON数组中读出。但是,如果我在使用键盘输入电脑写的,我可以看到在阵列中pssed关键$ P $。

i'm making a table with some field, with the option to add new rows. At the end, i will print all the field. The application i am going to do is for touch monitor, so i've made a new keyboard. The problem is that if I press a button of this keyboard, i can read the corrispondent input, but i can't read in the json array. But if i write in this input with the keyboard of computer, i can see the key pressed in the array.

下面是不是我的应用程序,它只是一个简单的例子向你展示我的问题:的 http://plnkr.co/edit/4cP2xSDRgvHG29RuA92N?p=$p$pview

Here isn't my application, it is just an easy example to show you my problem: http://plnkr.co/edit/4cP2xSDRgvHG29RuA92N?p=preview

下面是键盘的jQuery的:

here is the jQuery of KeyBoard:

    $(document).ready(function() {
  $('#myInput').click(function() {
    $('#n_keypad').fadeToggle('fast');
  });
  $('.done').click(function() {
    $('#n_keypad').hide('fast');
  });
  $('.numero').click(function() {
    if (!isNaN($('#myInput').val())) {
      if (parseInt($('#myInput').val()) === 0) {
        $('#myInput').val($(this).text());
      } else {
        $('#myInput').val($('#myInput').val() + $(this).text());
      }
    }
  });
  $('.neg').click(function() {
    if (!isNaN($('#myInput').val()) && $('#myInput').val().length > 0) {
      if (parseInt($('#myInput').val()) > 0) {
        $('#myInput').val(parseInt($('#myInput').val()) - 1);
      }
    }
  });
  $('.pos').click(function() {
    if (!isNaN($('#myInput').val()) && $('#myInput').val().length > 0) {
      $('#myInput').val(parseInt($('#myInput').val()) + 1);
    }
  });
  $('.del').click(function() {
    $('#myInput').val($('#myInput').val().substring(0, $('#myInput').val().length - 1));
  });
  $('.clear').click(function() {
    $('#myInput').val('');
  });
  $('.zero').click(function() {
    if (!isNaN($('#myInput').val())) {
      if (parseInt($('#myInput').val()) !== 0) {
        $('#myInput').val($('#myInput').val() + $(this).text());
      }
    }
  });
});

感谢您!!

推荐答案

使用角度insteted的jQuery。
这里是一个正在运行的例子。这是更容易和松散耦合。

Use angular insteted of jQuery. Here is a running example. It is more easy and loosely coupled.

HTML

<input type="text"  data-ng-model="food.Text" data-ng-click="food.showKeypad = true" />
<keypad data-show="food.showKeypad" data-text="food.Text" />

JS

app.directive('keypad', function($compile) {
      return {
          restrict: 'AE',
          scope : {
            show : '=',
            text : '='
          },
          link : function(scope, element, attrs, model){
            scope.type = function(){
                scope.text = scope.text+'0';
            };
            scope.done = function(){
                scope.show = false;
            };
            element.parent().append($compile(
                    '<div ng-show="show">'+
                    '<button ng-click="type()">0</button>'+
                    '<button ng-click="done()">x</button>'+
                    '</div>'
            )(scope));
         }
      };
    });

Plunker这里

这篇关于NG-重复角+触感键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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