8

I developing with Ionic framework and angularjs.

My app have about 5 menu and design like google play store

  • New product
  • Bestseller
  • Promotion
  • Store ...

How do swipe to move "New product" to Bestseller page,...(google store play - like)

This my route:

myApp.config(function ($routeProvider, $locationProvider) {
$routeProvider
    .when('/',
        {
            controller: 'NewProductController',
            templateUrl: 'app/views/newproduct.html'
        })
    .when('/bestseller',
        {
            templateUrl: 'app/views/bestseller.html',
            controller: 'BestsellerController'
        })

    .otherwise({ redirectTo: '/' });    

});

ng-swipe-left、ng-swipe-right を試しました:

<div ng-swipe-right=goToPage('bestseller')> 
     // new product page
</div>

$scope.goToPage = function (page) {        
    $location.url(page);
};

しかし、アニメーションではありません。

解決を助けてください。どうもありがとうございます。

4

2 に答える 2

4

角度のあるスワイプが機能しています(イオンではありませんが、角度の問題だと思います)。

1)モジュールとしてngAnimateとngTouchがあることを確認してください(もちろん、依存関係(jsファイル)としてhtmlファイルに追加してください:

angular.module('cbosApp', [
      'ngAnimate', //this!
      'ngTouch', // and this!
      'ngCookies',
      'ngResource',
      'ngSanitize',
      'ngRoute',
      'frapontillo.bootstrap-switch'    
    ])

2) ステートメントの前後の引用符 (") を忘れた

<div ng-swipe-right="goToPage('bestseller')"> 
 // new product page
</div>

$location をパラメーターとしてコントローラーに入れることを忘れないでください!

  angular.module('cbosApp')
  .controller('SettingsCtrl', function ($scope,$rootScope,$location) {});

あなたのやり方でやれば、あなたの機能はすべてのコントローラーで正しいです!

重要: テストする場合、クリックとリリースのクリックは DOM 要素 (ここでは div) で発生する必要があります。そうしないと機能しません。

于 2014-03-17T12:23:56.547 に答える