Angular 角材料:为什么'#自动';你有外派吗?

Angular 角材料:为什么'#自动';你有外派吗?,angular,angular-material,Angular,Angular Material,为什么这个ref#auto有赋值? 我不明白什么 这是第一个例子 示例:#auto=“matAutocomplete” {{水果} 取消 {{水果} 谢谢! 当指定一个值时,表示ref导出为。 在代码中:#auto=“matAutocomplete”您是说ref auto是matAutocomplete类型 . 注意:请参见“导出为:matAutocomplete” 接下来的代码中,您可以看到几个示例来了解这种行为: // inputRef1 is exported as elementRe

为什么这个ref#auto有赋值? 我不明白什么

这是第一个例子

示例:#auto=“matAutocomplete”


{{水果}
取消
{{水果}

谢谢!

当指定一个值时,表示ref导出为。 在代码中:#auto=“matAutocomplete”您是说ref auto是matAutocomplete类型 . 注意:请参见“导出为:matAutocomplete”

接下来的代码中,您可以看到几个示例来了解这种行为:

// inputRef1 is exported as elementRef (it has no assignment)
<input
  placeholder="New option..."
  #inputRef1
/>

// inputRef2 is exported as MatInput https://material.angular.io/components/input/api#MatInput
<input
  placeholder="New option..."
  matInput
  #inputRef2="matInput"
/>

// inputRef3 is exported as MatChipInput https://material.angular.io/components/chips/api#MatChipInput
<input
placeholder="New option..."
#inputRef3="matChipInput"
[matChipInputFor]="chipListRef"
/>

// For all examples you can 'transform' the type of element using 'read' property
@ViewChild('inputRef1', { static: false }) inputRef: ElementRef;
@ViewChild('inputRef1', { static: false, read: MatInput }) inputRef2: MatInput;
@ViewChild('inputRef1', { static: false, read: MatChipInput }) inputRef3: MatChipInput;
//inputRef1作为elementRef导出(它没有赋值)
//inputRef2作为MatInput导出https://material.angular.io/components/input/api#MatInput
//inputRef3作为MatChipInput导出https://material.angular.io/components/chips/api#MatChipInput
//对于所有示例,您都可以使用“read”属性“transform”元素的类型
@ViewChild('inputRef1',{static:false})inputRef:ElementRef;
@ViewChild('inputRef1',{static:false,read:MatInput})inputRef2:MatInput;
@ViewChild('inputRef1',{static:false,read:MatChipInput})inputRef3:MatChipInput;
// inputRef1 is exported as elementRef (it has no assignment)
<input
  placeholder="New option..."
  #inputRef1
/>

// inputRef2 is exported as MatInput https://material.angular.io/components/input/api#MatInput
<input
  placeholder="New option..."
  matInput
  #inputRef2="matInput"
/>

// inputRef3 is exported as MatChipInput https://material.angular.io/components/chips/api#MatChipInput
<input
placeholder="New option..."
#inputRef3="matChipInput"
[matChipInputFor]="chipListRef"
/>

// For all examples you can 'transform' the type of element using 'read' property
@ViewChild('inputRef1', { static: false }) inputRef: ElementRef;
@ViewChild('inputRef1', { static: false, read: MatInput }) inputRef2: MatInput;
@ViewChild('inputRef1', { static: false, read: MatChipInput }) inputRef3: MatChipInput;