Preventing / dealing with double button clicks in angular

前端 未结 13 1186
我寻月下人不归
我寻月下人不归 2020-11-27 19:53

In angular we can set up a button to send ajax requests like this in view:

... ng-click=\"button-click\"

and in controller:



        
13条回答
  •  暖寄归人
    2020-11-27 20:25

    I liked solution of user: zsong

    But ng-dblclick="return false;" give a problem(I'm using Chrome Windows7) at js console you can see the error.

    I can't comment (i don't have enough reputation to comment his solution)

    Just use only ng-disabled.

    As you can see at the plunker below if you have the two functions: ng-click and ng-dblclick And give a double click you will execute: 2 times click and 1 time dblclick

    
    

    The double click gives you 1.2, so you can't prevent the 2 clicks with ng-dblclick, just add one more behavior when the second click happens.

    Dblclick and click

    Jonathan Palumbo gave an example with ng-disabled work at this thread.

提交回复
热议问题