Angular2 How to get reference of HTML elements generated dynamically

前端 未结 4 1951
傲寒
傲寒 2020-12-30 20:33

I have this inputs generated dynamically:

  
4条回答
  •  忘掉有多难
    2020-12-30 21:17

    You can access the DOM by the elementRef.

    Inject it through your constructor by

    constructor(myElement: ElementRef) { ... }
    

    And access the DOM element by the nativeElement property

    myElement.nativeElement.select("#blabla")
    

提交回复
热议问题