javascript - How to access element's current style from directive in Angular? -
suppose have following code:
<div style="transform: translatex(100px);" applytranslatezdirective><div/> the directive required append translatez(...) value transform property instead of overwriting it.
the end result should like: transform: translatex(100px) translatez(...).
problem
the code below not work, because el's styles not yet initialized when ngoninit() called.
/////////////// // directive // /////////////// private initialtransform: string; constructor(private el: elementref) { } ngoninit() { this.initialtransform = this.el.nativeelement.style.transform; } what other ways access element's initial style?
p.s
please keep in mind, access other lifecycle hooks limited, because dealing directives.
Comments
Post a Comment