How to apply transform translate property to element using ngStyle in Angular2^
You can use [ngStyle]
as follows, assuming you have a $value
variable in your controller:
[ngStyle]="{'transform': 'translateX(' + $value + 'px)'}"
and suppose you want to change both the axis having controller variables $x , $y
[ngStyle]="{'transform': 'translate(' + $x + 'px, ' + $y + 'px)'}"
Alternatively you can use [style.transform]="'translateX('+$value+')'"
it is essentially the same thing but I prefer this syntax.