What does #id in input tag mean?

前端 未结 6 1187
挽巷
挽巷 2021-01-18 10:56

From this Angular.io tutorial, I show:


where I do not unde

6条回答
  •  别那么骄傲
    2021-01-18 11:42

    A template reference is used to give your controlling class a reference to an element. #searchBox will give you a reference to your input element if you define it in typescript like:

    @ViewChild('searchBox') searchBox;
    

    now you can use that reference to control or ask from your input element like:

    this.searchBox.nativeElement.focus();
    

提交回复
热议问题