-4

I have a element:

private elementRef: ElementRef;  

I have tried to get element name using this:

console.log(this.elementRef.nativeElement.name);
OPV
  • 1
  • 26
  • 81
  • 156
  • 2
    Possible duplicate of [How can I select an element in a component template?](https://stackoverflow.com/questions/32693061/how-can-i-select-an-element-in-a-component-template) – Kamil Naja Oct 31 '19 at 16:42

1 Answers1

2

Have you tried this...

Set value: this.elementRef.nativeElement.setAttribute("name", "myName");

or

Get value: this.elementRef.nativeElement.getAttribute("name");