Reputation: 5618
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)'
});
});
}
}
});
Upvotes: 10
Views: 17810
Reputation: 719
For Ionic icons v1, v2 specifically, the rotate property works only with the display property set to "inline" or "inline-block", it might work with other variations of inline as well.
Then you can rotate them normally using CSS
transform: rotate(90deg);
Upvotes: 8
Reputation: 141
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);
}
Upvotes: 14
Reputation: 2442
for some reason the <i>
element has to 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>
Upvotes: 0
Reputation: 5469
There is other variants of arrow:
ion-arrow-up-a
ion-arrow-right-a
ion-arrow-down-a
ion-arrow-left-a
Or... As I know, 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 have to check this url.
Upvotes: 6