Note that there are some explanatory texts on larger screens.

plurals
  1. POSelf rotating image using AngularJS
    text
    copied!<p>I am trying to create a self rotating image viewer in AngularJS. Sorry if the question seems stupid, but I can't figure it out the angularJS way. I know I can hack it there using jQuery, but I think it should doable in AngularJS alone.</p> <p>The HTML:</p> <pre><code>&lt;div ng-controller="rotatorController"&gt; &lt;div ng-switch on="pic" ng-animate=" 'animate' " id="rotator"&gt; &lt;div ng-switch-when="1"&gt;&lt;img src="/home/1.jpg"&gt;&lt;/div&gt; &lt;div ng-switch-when="2"&gt;&lt;img src="/home/2.jpg"&gt;&lt;/div&gt; &lt;div ng-switch-when="3"&gt;&lt;img src="/home/3.jpg"&gt;&lt;/div&gt; &lt;/div&gt; &lt;div style="position: absolute; top: 600px" id="indexbuttons"&gt; &lt;button ng-click="pic = '1';" class="button"&gt;1&lt;/button&gt; &lt;button ng-click="pic = '2';" class="button"&gt;2&lt;/button&gt; &lt;button ng-click="pic = '3';" class="button"&gt;3&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The CSS:</p> <pre><code>div#rotator { margin: 0; padding: 0; border: 0; position: absolute; } .animate-enter, .animate-leave { -webkit-transition: 825ms cubic-bezier(0.455, 0.030, 0.515, 0.955) all; -moz-transition: 825ms cubic-bezier(0.455, 0.030, 0.515, 0.955) all; -ms-transition: 825ms cubic-bezier(0.455, 0.030, 0.515, 0.955) all; -o-transition: 825ms cubic-bezier(0.455, 0.030, 0.515, 0.955) all; transition: 825ms cubic-bezier(0.455, 0.030, 0.515, 0.955) all; position: absolute; } .animate-enter { left: 100%; } .animate-enter.animate-enter-active { left: 0; } .animate-leave { left: 0; } .animate-leave.animate-leave-active{ left: -100%; } </code></pre> <p>How do I send click event to indexbuttons in angularJS? Or is there a better way to loop those pictures?</p> <p>Plunker: <a href="http://plnkr.co/edit/QiYidN?p=catalogue" rel="nofollow">http://plnkr.co/edit/QiYidN?p=catalogue</a></p> <p>Thank you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload