在移动设备上,我如何“输入”在type =“number”输入中提交表单?

时间:2022-11-24 11:00:18

I'm using AngularJS and ng-submit like this:

我正在使用AngularJS和ng-submit,如下所示:

<form ng-submit="submit(foo); foo='';">
  <input type="number" ng-model="foo">
</form>

In Chrome on a desktop machine, I can press enter while in the input to submit the form (which calls submit(foo) in this case).

在桌面计算机上的Chrome中,我可以在输入中按Enter键以提交表单(在这种情况下调用submit(foo))。

In Chrome for Android (KitKat), it doesn't work. BUT, if I change the input to type="text" then it does work when I press "Go."

在Chrome for Android(KitKat)中,它不起作用。但是,如果我将输入更改为type =“text”,那么当我按“Go”时它会起作用。

How can I get the form to behave like it does for input type="text" with input type="number"? I'm using type="number" because I want the device to bring up the numerical keyboard.

如何使表单的行为类似于输入类型=“数字”的输入类型=“文本”?我正在使用type =“number”,因为我希望设备调出数字键盘。

Here's a plunkr that illustrates the problem: http://plnkr.co/edit/4WJfdoKgXu7o6ZsM8WFx?p=preview (or http://goo.gl/IiQzGf if you're on a mobile device).

这是一个说明问题的插件:http://plnkr.co/edit/4WJfdoKgXu7o6ZsM8WFx?p=preview(或http://goo.gl/IiQzGf,如果你在移动设备上)。

Edit:

Listening for enter with JavaScript does not work: http://plnkr.co/edit/07QGA1s4UCyop8IB8Dmx?p=preview

使用JavaScript搜索输入不起作用:http://plnkr.co/edit/07QGA1s4UCyop8IB8Dmx?p = preview

Edit 2:

It's not an AngularJS problem. It's an HTML problem: http://embed.plnkr.co/ZVD0ZtmEutWZr7P7vq2b/preview

这不是AngularJS问题。这是一个HTML问题:http://embed.plnkr.co/ZVD0ZtmEutWZr7P7vq2b/preview

1 个解决方案

#1


0  

I tried the last plunker (simple HTML) on Android N on a Samsung Galaxy S8, and the submit worked on both fields. It may be an issue with the specific Android version

我在三星Galaxy S8上尝试了Android N上的最后一个plunker(简单HTML),并且提交在两个领域都有效。这可能是特定Android版本的问题

#1


0  

I tried the last plunker (simple HTML) on Android N on a Samsung Galaxy S8, and the submit worked on both fields. It may be an issue with the specific Android version

我在三星Galaxy S8上尝试了Android N上的最后一个plunker(简单HTML),并且提交在两个领域都有效。这可能是特定Android版本的问题