Rotate ionion on the page

I want to display directions with an arrow and was thinking of using a standard ionic arrow for the direction. Can I rotate the arrow up in any direction?

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)'
                    });
                });
            }
    }
});

      

+3


source to share


4 answers


There are other options for arrows:

ion-arrow-up-a
ion-arrow-right-a
ion-arrow-down-a
ion-arrow-left-a

      

Or ... As I know the ionic framework is HTML5 based, so you can use CSS styles.



.style {
    -moz-transform: rotate(15deg);
    -webkit-transform: rotate(15deg);
    -o-transform: rotate(15deg);
    -ms-transform: rotate(15deg);
    transform: rotate(15deg);
}

      

If you want dynamic rotation you should check this url .

+5


source


As 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);
}

      

+4


source


Unlike IonicIcons, the rotate property only works with a display property set to "inline" or "inline block", it can work with other inline options as well.

Then you can rotate them with CSS

transform: rotate(90deg);

      

+1


source


for some reason the element <i>

needs to have its own display: inline-block

css style to rotate successfully:

controller code:

$scope.angle = 90

      

HTML:

<i class="ion-arrow-up-c" style="display: inline-block; transform: rotate({{angle}}deg);"></i>

      

0


source







All Articles