Accessing dom elements in angular in an angular way

I have a usecase where I want to access the dom element by its id and set some value in it.

I achieved it using

<HTMLInputElement>document.getElementById('test_id')).value = '123';

We are using third party api where we dont have any control over test_id that is test_id is not set up by us.

I want to know is there any angular way to avoid accessing element by document.getElementById?

If the test_id is in our control then we can use @ViewChild but here we can not use. So is there any way so that I can access the element by id in an angular way?

11 thoughts on “Accessing dom elements in angular in an angular way”

Leave a Comment