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
You can do the rotation by setting the CSS in the directive
app.directive('rotate', function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
scope.$watch(attrs.degrees, function (rotateDegrees) {
console.log(rotateDegrees);
var r = 'rotate(' + rotateDegrees + 'deg)';
element.css({
'-moz-transform': r,
'-webkit-transform': r,
'-o-transform': r,
'-ms-transform': r
});
});
}
}
});
Hope it can shed some light on.
Demo