Angular 5 – add style to specific element dynamically
I’m super late to this party, but NO! DO NOT USE DOCUMENT.QUERYSELECTOR. That is NOT how you style an Angular DOM element! <div [ngStyle]=”{‘top.px’: divStyle}”> Then in your component, you have ngAfterViewInit() { this.divStyle = 200; }