Rotate an ionicon on the page

El Dude picture El Dude · Jun 16, 2015 · Viewed 14.5k times · Source

I want to display directions with an arrow and was thinking to use the standard ionic arrow for the direction. Can I rotate the up arrow into any direction somehow?

ion-arrow-up-a

Here is an attempt from the comments below

<i class="icon ion-arrow-up-a" rotate degrees="90"></i>


angular.module('app.customDirectives', []).directive('rotate', function() {
      return {
            link: function(scope, element, attrs) {
                // watch the degrees attribute, and update the UI when it changes
                scope.$watch(attrs.degrees, function(rotateDegrees) {
//                  console.log(rotateDegrees);
                    //transform the css to rotate based on the new rotateDegrees
                    element.css({
                        '-moz-transform': 'rotate(' + rotateDegrees + 'deg)',
                        '-webkit-transform': 'rotate(' + rotateDegrees + 'deg)',
                        '-o-transform': 'rotate(' + rotateDegrees + 'deg)',
                        '-ms-transform': 'rotate(' + rotateDegrees + 'deg)'
                    });
                });
            }
    }
});

Answer

sam pierce picture sam pierce · Jan 4, 2016

Similar to above, this is how I did it...

HTML:

<i class="ion-arrow-up-c rotate-90">

CSS:

.rotate-90 {
  display: inline-block; 
  transform: rotate(90deg);
}