Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角材质自动完成是否不触发一次更改事件?_Angular_Autocomplete_Angular Material - Fatal编程技术网

Angular 角材质自动完成是否不触发一次更改事件?

Angular 角材质自动完成是否不触发一次更改事件?,angular,autocomplete,angular-material,Angular,Autocomplete,Angular Material,我有一个基本的自动完成。一个对象列表,我从中拉出字符串属性列表,并希望对其进行筛选和选择。你知道为什么一切正常吗?我看到了名单。但当我在框中输入时,过滤器不会发生 <mat-form-field> <input type="text" placeholder="Filter by Last Name" [formControl]="fcOnBehalfLastName&qu

我有一个基本的自动完成。一个对象列表,我从中拉出字符串属性列表,并希望对其进行筛选和选择。你知道为什么一切正常吗?我看到了名单。但当我在框中输入时,过滤器不会发生

            <mat-form-field>
                <input type="text" placeholder="Filter by Last Name" [formControl]="fcOnBehalfLastName" matInput
                    [matAutocomplete]="auto">
                    <mat-autocomplete #auto="matAutocomplete">
                        <mat-option *ngFor="let eln of allEmployeesLastNames" [value]="eln">
                          {{eln}}
                       </mat-option>
                   </mat-autocomplete>
            </mat-form-field>


  fcOnBehalfLastName = new FormControl();
  filteredLastNames: Observable<any>;
  allEmployeesLastNames: string[];

  constructor(private fb: FormBuilder) {
    console.log('-----OrderStep1xComponent');
  }

  private _filter(value: string): string[] {
    const filterValue = value.toLowerCase();
    return this.allEmployeesLastNames.filter(eln => eln.toLowerCase().includes(filterValue));
  }

  ngOnChanges(changes: SimpleChanges) {
    if (changes.allEmployees && changes.allEmployees.currentValue) {
      this.allEmployeesLastNames = this.allEmployees.map(o => o.lastName);
    }
  }

  ngOnInit(): void {
    this.employeeFilter = new Employee();

    this.filteredLastNames = this.fcOnBehalfLastName.valueChanges
      .pipe(
        startWith(''),
        map(value => this._filter(value))
      );

{{eln}}
fcOnBehalfLastName=新FormControl();
filteredLastNames:可观察;
allEmployeesLastNames:string[];
构造函数(私有fb:FormBuilder){
log('----OrderStep1xComponent');
}
private_过滤器(值:string):string[]{
常量filterValue=value.toLowerCase();
返回这个.allEmployeesLastNames.filter(eln=>eln.toLowerCase().includes(filterValue));
}
ngOnChanges(更改:SimpleChanges){
if(changes.allEmployees&&changes.allEmployees.currentValue){
this.allEmployeesLastNames=this.allEmployees.map(o=>o.lastName);
}
}
ngOnInit():void{
this.employeeFilter=新员工();
this.filteredLastNames=this.fcOnBehalfLastName.valueChanges
.烟斗(
startWith(“”),
映射(值=>this.\u过滤器(值))
);