Here is the component template
template: `<h1 class = "dragStyle" [drag] = "true">DRAG THIS ELEMENT</h1>`,
styles : [.dragStyle{
margin : 12px;
}
]
Here is the constructor of [drag] attribute directive-
constructor(
private _el: ElementRef,
private _renderer : Renderer,
@Attribute('class') type : string) {
console.log(type);
I need to access the value of margin property associated with the dragStyle class for some computations.
Shiv Kumar
Angular2 NodeJs MongoDb
I found the solution.
let margin = getComputedStyle(this._el.nativeElement).getPropertyValue('margin');