Ui-sref does not work with ng-click (angular-touch) if used without jQuery

I find it difficult to remove jQuery from our application. Main problem: simple link combining ng-clickwith ui-sref:

<a data-ui-sref="main2" data-ng-click="reportClick()">Link</a>

Result: ng-clickfires, ui-srefno. This only happens when using angular-touch without jQuery as a dependency and a mobile browser, or emulating a mobile device in the new Chrome 32 (I used Nexus 4 as the target for emulation).

Example: http://jsfiddle.net/scheffield/AEfMm/

To see the effect: http://jsfiddle.net/scheffield/AEfMm/show in a mobile browser

I already did a little research and found out that the event object is broken:

element.bind("click", function(e) {
    var button = e.which || e.button;

    if ((button === 0 || button == 1) && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
      // HACK: This is to allow ng-clicks to be processed before the transition is initiated:
      $timeout(function() {
        scope.$apply(function() {
          $state.go(ref.state, params, { relative: base });
        });
      });
      e.preventDefault();
    }
  });

, , angular.noop.

?

+4

Source: https://habr.com/ru/post/1523876/


All Articles