2016-09-12 127 views
1

我有一個使用turn.js的Ionic v1項目,但現在我使用了Ionic v2。 我有導入使用jQuery的turn.js的問題。如何在離子2中使用turn.js?

angular.module('albumController', []) 

.directive('flipbook', function() { 
return { 
    restrict: 'E', 
    replace: true, 
    compile: function (element, attrs) { 
     element.turn({ 
      width: '300px', 
      height: '300px', 
      pages: 8 
     }).turn('peel', 'br'); 

     element.addClass('flipbook'); 
     return function (scope, el) { 
      el.on('click', '[data-page]', function (e) { 
       el.turn('page', $(e.target).data('page')); 
      }); 
     }; 
    }, 
    templateUrl: "flipbook.html" 
} 
}); 

謝謝!

+0

您有什麼問題。更好的解釋會幫助人們找到答案。 – Fencer04

+0

@ Fencer04我不能在$('#flipbook')中使用方法「turn」。turn('next'); vs代碼表示屬性'轉向'在typeof jQuery中不存在 –

回答

0

我不知道你是否已經有了答案。對我來說,我做到以下幾點:。

  1. 中安裝jQuery的離子(檢查here
  2. npm install --save turn.js

  3. import $ from "jquery"; import "turn.js";

只是你可以使用$()轉();

希望對您有所幫助:D