Javascript 角垫自动完成不';t显示/显示从后端返回的对象的下拉列表

Javascript 角垫自动完成不';t显示/显示从后端返回的对象的下拉列表,javascript,angular,angular-material,Javascript,Angular,Angular Material,我已经尝试实现mat autocomplete(Angular Material)和.TS代码,并从后端API返回数据。 但是“自动完成”不会在下拉列表中自动显示对象 按照我的代码: 导出类VendaComponent实现OnInit{ public produtoAutoComplete:Observable=null; public-vendaForm=new-FormControl(); 文达斯:文达[]=[]; produtos:produtos; isLoading=false; 构

我已经尝试实现mat autocomplete(Angular Material)和.TS代码,并从后端API返回数据。 但是“自动完成”不会在下拉列表中自动显示对象

按照我的代码:

导出类VendaComponent实现OnInit{
public produtoAutoComplete:Observable=null;
public-vendaForm=new-FormControl();
文达斯:文达[]=[];
produtos:produtos;
isLoading=false;
构造函数(私有VendaService:VendaService,私有ProdutService:ProdutService,私有toastr:ToastrService){}
查找(值:字符串):可观察{
返回此.produtoService.search(value.toLowerCase()).pipe(
//将github结果的item属性映射为我们的返回对象
映射(results=>results.produtos),
//捕捉错误
catchError(=>{
返回(空);
})
);
}
恩戈尼尼特(){
this.produtoAutoComplete=this.vendaForm.valueChanges.pipe(
startWith(“”),
//延迟发射
去BounceTime(300),
//map(options=>options?this.filter(options):this.produtos.slice()
开关映射(值=>{
如果(值!=''){
//从github查找
返回此.lookup(值);
}否则{
//如果不存在值,则返回null
返回(空);
}
})
);

}
过了好几个小时,我找到了这个问题的解决方案

组件的TS:

导出类VendaComponent实现OnInit{
public-vendaForm=new-FormControl();
文达斯:文达[]=[];
结果:任何[];
isLoading=false;
构造函数(私有VendaService:VendaService,私有ProdutService:ProdutService,私有toastr:ToastrService){}
恩戈尼尼特(){
this.vendaForm.valueChanges.subscribe(
术语=>{
如果(术语!=''){
this.produtoService.search1(term).subscribe(
数据=>{
this.results=任何[]数据;
控制台日志(数据);
})
}
})
}