How to pass data dynamically from angular 6 typescript to animateTransform "from" attribute?

448 Views Asked by At

I've tried several ways, below are my attempts:

In my typescript file, I set the value as:

this.value = "130"; //for first method
this.rotation = "130 192 190"; //for second method

While in component.html

<animateTransform attributeName="transform"
                  type="rotate"
                  from="{{value}} 192 190"
                  to="0 192 190"
                  dur="3s"></animateTransform>

second method:

<animateTransform attributeName="transform"
                  type="rotate"
                  [attr.from]="rotation"
                  to="0 192 190"
                  dur="3s"></animateTransform>

both methods arent working. Any way to do this?

1

There are 1 best solutions below

2
On BEST ANSWER

Just take the good parts of both:

this.value = "130"

With

<animateTransform attributeName="transform"
                  type="rotate"
                  [attr.from]="value + ' 192 190'"
                  to="0 192 190"
                  dur="3s"></animateTransform>