<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.
ts:
public id = 'my-input';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.