colouredFunk
colouredFunk

Reputation: 788

Are Angular 2/3 Directives compatible with Angular 4

I would like to use this Swipe Directive - https://github.com/gajus/angular-swing but it looks like it's not written for Angular IO (Angular JS 4)

Upvotes: 0

Views: 92

Answers (1)

Alexander Staroselsky
Alexander Staroselsky

Reputation: 38817

This will most certainly NOT work with Angular 2+. From the documentation:

AngularJS directive for Swing: A swipeable cards interface. The swipe-left/swipe-right for yes/no input. As seen in apps like Jelly and Tinder, and many others.

It is specifically for AngularJS, as in Angular 1.x. This can be confirmed by looking at the source code. It's utilizing $scope and $apply as well as syntax for declaring Angular 1.x directives such as link functions.

function SwingStackController($scope, $element, $attrs, $parse) {
  // ...
}

SwingStackController.$inject = ['$scope', '$element', '$attrs', '$parse'];

function swingStack() {
  return {
    restrict: 'A',
    controller: SwingStackController,
  }
}

You could instead consider a library such as HammerJS which libraries such as Angular Material 2 use for touch gestures.

Upvotes: 1

Related Questions