Reputation: 1623
Is it possible by using angular 8 with typescript to get value from input by know only id of this element?
Upvotes: 2
Views: 8031
Reputation: 7949
You can simple add this code in your .ts file inside the block where you want value of input from id
(<HTMLInputElement>document.getElementById("unitPrice")).value;
Upvotes: 6
Reputation: 2068
your best bet would be
@ViewChild("dataBlock") block: ElementRef;
clearContent() {
this.block.nativeElement.innerHTML = "";
}
as the angular way because in ng app it is never meant to be work in browser
you can run Angular in a web worker which doesn't have direct access to the DOM
but if you are firm on id
method then you can definitely use classic javascript methods document.getElementById
Upvotes: 0