AngularJS: Call the ng-submit event outside the form

前端 未结 10 1477
渐次进展
渐次进展 2020-12-09 02:07

I\'m a fish in AngularJS and I have this scenario.

10条回答
  •  情歌与酒
    2020-12-09 02:38

    There is a solution that works for me:

    http://jsbin.com/ODaFaGU/3/edit

    Check out the PART 2 and PART 3.

    There are two solutions inside.

    One for the regular form submit buttons - it allows you to tap the buttons without a delay, but also ensures that pressing the "enter" key in any of the form fields will trigger a submit.

    Secondly there is an additional eventHandler that combines the click, tap and keydown[enter] events into a single one - this ensures that you can hit your controls as well with the keyboard, as with a click on desktop, and a tap on mobile(without hitting the click event twice) devices.

    If you have any problems with this, give me a comment, I'll fix it.

提交回复
热议问题