ฉันกำลังพยายามใช้ส่วนประกอบการเติมข้อความอัตโนมัติของ Angular ในโครงการ Angular 2 ของฉัน ฉันเพิ่มสิ่งต่อไปนี้ในแม่แบบของฉัน
<md-input-container>
   <input mdInput placeholder="Category" [mdAutocomplete]="auto" [formControl]="stateCtrl">
</md-input-container>
<md-autocomplete #auto="mdAutocomplete">
   <md-option *ngFor="let state of filteredStates | async" [value]="state">
      {{ state }}
   </md-option>
</md-autocomplete>ต่อไปนี้เป็นองค์ประกอบของฉัน
import {Component, OnInit} from "@angular/core";
import {ActivatedRoute, Router} from "@angular/router";
import {FormControl} from "@angular/forms";
@Component({
    templateUrl: './edit_item.component.html',
    styleUrls: ['./edit_item.component.scss']
})
export class EditItemComponent implements OnInit {
    stateCtrl: FormControl;
    states = [....some data....];
    constructor(private route: ActivatedRoute, private router: Router) {
        this.stateCtrl = new FormControl();
        this.filteredStates = this.stateCtrl.valueChanges.startWith(null).map(name => this.filterStates(name));
    }
    ngOnInit(): void {
    }
    filterStates(val: string) {
        return val ? this.states.filter((s) => new RegExp(val, 'gi').test(s)) : this.states;
    }
}ฉันได้รับข้อผิดพลาดต่อไปนี้ ดูเหมือนว่าformControlไม่พบคำสั่ง
ไม่สามารถผูกกับ 'formControl' ได้เนื่องจากไม่ใช่คุณสมบัติที่รู้จักของ 'อินพุต'
ปัญหาที่นี่คืออะไร
formcontrol(ตัวพิมพ์เล็ก) มากกว่าformControl- ถ้าคุณใช้แม่แบบผ่าน webpack html-loader สิ่งนี้จะช่วยได้: stackoverflow.com/a/40626329/287568
                

formControlคุณจะต้องนำเข้าReactiveFormsModuleที่คุณโมดูลไม่rootModule ในกรณีที่คุณใช้FormControlในโมดูลคุณสมบัติของคุณ