2016-01-12 82 views
0

有人請給我一個例子如何在瀏覽器上滑動一些文本? 我有3個文本,我希望文本從循環中的一個接一個地從右向左滑動。AngularJS文本滑塊示例

我的HTML代碼

<div class="intro-titles"> 
     <h1 class="slide-animation" ng-hide='currentIndex != 1'>{{'HOME.INTROTITLES.TITLE1' | translate}}</h1> 
     <h1 class="slide-animation" ng-hide='currentIndex != 2'>{{'HOME.INTROTITLES.TITLE2' | translate}}</h1> 
     <h1 class="slide-animation" ng-hide='currentIndex != 3'>{{'HOME.INTROTITLES.TITLE3' | translate}}</h1> 
    </div> 

我的控制器

$scope.currentIndex = 1; 

    $interval(function(){ 
     if($scope.currentIndex == 3){ 
      $scope.currentIndex = 1; 
     }else{ 
      $scope.currentIndex += 1; 
     } 
     console.log($scope.currentIndex); 
    }, 4000); 

回答

0

有沒有必要寫JS代碼,你可以使用HTML marquee標籤

+0

這由以下是過時的標籤[MDN] (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee),而W3C則表示[反對](https://en.wikipedia.org/wiki/Marquee_element)。 –