Faster clicks on buttons and checkboxes with phonegap & angular

To be able to click on buttons without the default 300ms delay on mobile webapps you need to make the browser respond to touch events instead of click events. There are several options to enable that, fastclick might be the most popular all round solution. For angular there is the ngTouch module

With ngTouch js in place you enable it just by adding the module to your app and it will automatically boost all your ng-click’s.

angular.module('myApp', ['ngTouch']);

So a regular button will respond immediately rather than after that small default delay.

However, it will not change any behaviour for checkboxes – unless you add a ngclick to them aswell. And if a checkbox is wrapped inside a label, or the two of them inside a div, simply put the ngclick on the div:

<li ng-repeat="option in model.options" class="list-group-item" ng-click="option.checked=!option.checked">
<input type="checkbox" ng-model="option.checked">
<label>
{{option.text}}
</label>
</li>


 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s