Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Angular中获取元素名称?_Angular_Angular8 - Fatal编程技术网

如何在Angular中获取元素名称?

如何在Angular中获取元素名称?,angular,angular8,Angular,Angular8,我有一个要素: private elementRef: ElementRef; 我已尝试使用以下方法获取元素名称: console.log(this.elementRef.nativeElement.name); 你试过这个吗 设定值: this.elementRef.nativeElement.setAttribute(“name”、“myName”) 或 获取值: this.elementRef.nativeElement.getAttribute(“名称”)可能存在的重复项

我有一个要素:

private elementRef: ElementRef;  
我已尝试使用以下方法获取元素名称:

console.log(this.elementRef.nativeElement.name);
你试过这个吗

设定值:
this.elementRef.nativeElement.setAttribute(“name”、“myName”)

获取值:
this.elementRef.nativeElement.getAttribute(“名称”)

可能存在的重复项