Avatar ·

错误:在Angular Material中,'formControl'不是'input'的已知属性

大家好!我是Angular和TypeScript的新手,在使用Angular Material的自动完成功能时遇到了一个问题。 我创建了一个带有输入字段的组件,并希望将`formControl`绑定到它以管理表单状态。这是我的代码: **app.component.ts:** ```typescript import { Component, OnInit } from '@angular/core'; import { FormControl } from '@angular/forms'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent implements OnInit { myControl = new FormControl(''); options: string[] = ['One', 'Two', 'Three']; ngOnInit() {} } ``` **app.component.html:** ```html {{ option }}