Javascript '#';在html元素内部签名

Javascript '#';在html元素内部签名,javascript,angular,Javascript,Angular,我发现了我所不知道的信号 <input type="file" [multiple]="multiple" #fileInput> <upload-drawing #fu (change)="fu.upload()" [multiple]="true"></upload-drawing> export class DrawingUploadComponent { @Input() multiple: boolean = false; @ViewCh

我发现了我所不知道的信号

<input type="file" [multiple]="multiple" #fileInput>
<upload-drawing #fu (change)="fu.upload()" [multiple]="true"></upload-drawing>

export class DrawingUploadComponent
{

  @Input() multiple: boolean = false;
  @ViewChild('fileInput') inputEl: ElementRef;

  constructor(private http: Http) {}

  upload() {
    let inputEl: HTMLInputElement = this.inputEl.nativeElement;
    let fileCount: number = inputEl.files.length;
    let formData = new FormData();
    if (fileCount > 0) {
      for (let i = 0; i < fileCount; i++) {
        formData.append('file', inputEl.files.item(i));
      }
      this.http
        .post('http://localhost:8080/upload', formData).toPromise().then(() => console.log('success')).catch(() => console.log('error'));
    }
  }
}

导出类DrawingUploadComponent
{
@输入()倍数:布尔值=false;
@ViewChild('fileInput')inputEl:ElementRef;
构造函数(私有http:http){}
上传(){
让inputEl:HTMLInputElement=this.inputEl.nativeElement;
let fileCount:number=inputEl.files.length;
设formData=new formData();
如果(文件计数>0){
for(设i=0;iconsole.log('success')).catch(()=>console.log('error'));
}
}
}
我对里面的这些“#”符号和标签感到困惑。它们是什么,插入它们的目的是什么。我可以看出这是某种标识符,因为
@ViewChild('fileInput')
还有更多吗?

这些是

模板引用变量通常是对模板中DOM元素的引用。它也可以是对角度组件、指令或web组件的引用

它们允许模板的不同部分共享数据。线条

<input type="file" [multiple]="multiple" #fileInput>

将创建一个
fileInput
变量,供模板的其他部分或角度组件使用。

这些是

模板引用变量通常是对模板中DOM元素的引用。它也可以是对角度组件、指令或web组件的引用

它们允许模板的不同部分共享数据。线条

<input type="file" [multiple]="multiple" #fileInput>


将创建一个
fileInput
变量,供模板的其他部分或角度组件使用。

在ts中,您直接使用ViewChild访问输入。它基本上类似于在javascript中调用
document.getElementById

我在处理文件时使用了类似的代码。

在ts中,您可以使用ViewChild直接访问输入。它基本上类似于在javascript中调用
document.getElementById
。 我在处理文件时使用了类似的代码。

简单地说,用于为组件创建本地变量。简单地说,用于为组件创建本地变量