大佬教程收集整理的这篇文章主要介绍了无法绑定到’formControl’,因为它不是’input’的已知属性 – angular2材质自动完成问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<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 = [...@L_638_3@me 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; } }
这是什么问题?
import {FormsModule,ReactiveFormsModulE} from '@angular/forms'; @NgModule({ imports: [ BrowserModule,FormsModule,ReactiveFormsModule,MaterialModule,],... }) export class AppModule {}
以上是大佬教程为你收集整理的无法绑定到’formControl’,因为它不是’input’的已知属性 – angular2材质自动完成问题全部内容,希望文章能够帮你解决无法绑定到’formControl’,因为它不是’input’的已知属性 – angular2材质自动完成问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。