What does #id in input tag mean?

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

From this Angular.io tutorial, I show:


where I do not unde

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 12:01

    It is used as an element selector within a component...

    component.html

    
    

    component.ts

    @ViewChild('searchBox') input; 
    
    ngAfterViewInit() {
      console.log(input.nativeElement); // logs the javascript object for the element.
      console.log(this.input.nativeElement.value); // logs 4
    }
    

提交回复
热议问题