简体   繁体   中英

Are Angular 2/3 Directives compatible with Angular 4

我想使用此滑动指令-https: //github.com/gajus/angular-swing,但看起来它不是为Angular IO(Angular JS 4)编写的

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM