[英]I am using Mat Autocomplete in angular's latest version using it normally in my project getting this type of error
<form class="example-form">
<mat-form-field class="example-full-width">
<input type="text" placeholder="Pick one" aria-label="Number" matInput [formControl]="myControl" [matAutocomplete]="auto" for="id" >
</mat-form-field>
<mat-autocomplete #auto="matAutocomplete" id="id">
<mat-option *ngFor="let option of options" [value]="option">
{{ option }}
</mat-option>
</mat-autocomplete>
</form>
import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
@Component({
selector: 'app-auto',
templateUrl: './auto.component.html',
styleUrls: ['./auto.component.css']
})
export class AutoComponent implements OnInit {
constructor() { }
ngOnInit() {
}
myControl: FormControl = new FormControl();
options = [
'One',
'Two',
'Three'
];
}
I am getting this error when i am using it in my project in which i used material design bootstrap . 在我使用材料设计引导程序的项目中使用它时,出现此错误。
You are using id
but never declared it anywhere. 您正在使用
id
但从未在任何地方声明它。
ts: TS:
public id = 'my-input';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.