How do you rotate image in angularjs

前端 未结 3 958
[愿得一人]
[愿得一人] 2021-01-03 03:36

Hi I have an image that I want to rotate. There are two buttons left and right which rotate the image 45 degrees in opposite directions. I tried creating a directive using

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-03 03:59

    I just wanted to tell you my solution about rotating.

    
    
    

    Here rd states for rotate degree time(x1,x2,x3,x4 -x4 =360 then resetting it to 0 ) Say that you have an ng-repeat for images in there created img ids.and in this span's ng-click I rotate the image by applying css .

    $scope.RotateImage = function (id,deg) {
        var deg = 90 * deg;
        $('#' + id).css({
            '-webkit-transform': 'rotate(' + deg + 'deg)',  //Safari 3.1+, Chrome  
            '-moz-transform': 'rotate(' + deg + 'deg)',     //Firefox 3.5-15  
            '-ms-transform': 'rotate(' + deg + 'deg)',      //IE9+  
            '-o-transform': 'rotate(' + deg + 'deg)',       //Opera 10.5-12.00  
            'transform': 'rotate(' + deg + 'deg)'          //Firefox 16+, Opera 12.50+  
    
        });
    }
    

    Just take as an Alternative , any comments will be appreciated .

提交回复
热议问题