2017-06-13 58 views
1

我是新的離子 - 有棱角的世界。 我想爲我的項目放一個動畫類,但基於表達式的類是改變。即奇數項目想要左移動畫,甚至有權向右移動。ng表達式中的動畫類不工作離子3

<ion-item class="{{'list_item slideInLeft'}}" 

不工作,但

<ion-item class="list_item slideInLeft" 

動畫作品

我需要'類,以便能夠投入到工作中表達:

class="{{i%2==0 ? 'list_item slideInLeft':'list_item slide-in-both-ways'}}" 

我也試過了:

ng-class-odd="'list_item slideInLeft'" ng-class-even="'list_item slideInLeft'" 

ng-class ="{ odd: 'list_item slideInLeft', even:'list_item slideInLeft'}" 

沒有運氣。

有人有想法,讚賞!

離子信息(如果需要)

global packages: 

@ionic/cli-utils : 1.4.0 
Ionic CLI  : 3.4.0 

local packages: 

@ionic/app-scripts    : 1.3.7 
@ionic/cli-plugin-ionic-angular : 1.3.1 
Ionic Framework     : ionic-angular 3.3.0 

System: 

Node  : v6.10.0 
OS   : Windows 10 
Xcode  : not installed 
ios-deploy : not installed 
ios-sim : not installed 
npm  : 3.10.10 

回答

0

你可以使用納克級類似下面....我只是用我的班顏色,讓你與你的領域,以取代和值

var app = angular.module('plunker', []); 
 

 
app.controller('MainCtrl', function($scope) { 
 
    $scope.name=[]; 
 
    for(var i=0;i<10;i++){ 
 
    $scope.name.push(i); 
 
    } 
 
});
/* Put your css in here */ 
 

 
.red{ 
 
    color:red; 
 
} 
 
.blue{ 
 
    color:blue; 
 
}
<!DOCTYPE html> 
 
<html ng-app="plunker"> 
 

 
    <head> 
 
    <meta charset="utf-8" /> 
 
    <title>AngularJS Plunker</title> 
 
    <script>document.write('<base href="' + document.location + '" />');</script> 
 
    <link rel="stylesheet" href="style.css" /> 
 
    <script data-require="[email protected]" src="https://code.angularjs.org/1.4.12/angular.js" data-semver="1.4.9"></script> 
 
    <script src="app.js"></script> 
 
    </head> 
 

 
    <body ng-controller="MainCtrl"> 
 
    <p ng-repeat="i in name track by $index" ng-class={red:$index%2==0,blue:$index%2!==0}>{{i}}</p> 
 
    </body> 
 

 
</html>

+0

我的表情工作以及..但動畫發生。 即它正確評估並給出正確的關聯類,但它是一個動畫,我不看它動畫。但如果我沒有表達式直接放動畫類,動畫的作品! –