How to get checkboxes working with ng-touch?

310 Views Asked by At

Forms elements like checkboxes and radio buttons seem to not work with touch libraries like ng-touch. Any workaround or solutions for the same ?

1

There are 1 best solutions below

1
Lotus91 On

You can create another directive that simulates a click event to replace ngTouch's ng-click version for that specific problem.

.directive('basicClick', function($parse, $rootScope) {
 return {
  compile: function(elem, attr) {
    var fn = $parse(attr.basicClick);
    return function(scope, elem) {
     elem.on('click', function(e) {
       fn(scope, {$event: e});
       scope.$apply();
      });
     };
    }
  };
});