I am using Angular 5.2 in my project and new to the angular framework. My component html is looking like this:-
I want to add the style="top:200px;" dynamically to the highlighted element with class="app-alerts" in the above screenshot in the angular ts code. The div element with class "app-alerts" get added to the DOM on the render.
Please suggest the code changes.
As per our comments, You should be using document.querySelector
after a life cycle hook
ngAfterViewInit() {
(document.querySelector('.app-alerts') as HTMLElement).style.top = '150px';
}