Autocomplete 角度5和角度材质2:初始自动完成

Autocomplete 角度5和角度材质2:初始自动完成,autocomplete,angular5,angular-material2,Autocomplete,Angular5,Angular Material2,我使用的是带角材质的Angular 5 我有一份文件清单。我得到表单中的第一个文档数据,它将由用户填写 我添加了一个自动完成字段,用于检索数据库中的患者数据。 使用它之后,我验证了我的表单,并获得了第二个文档数据,但我也遇到了一个关于自动完成字段的问题: "ERROR TypeError: Cannot read property 'subscribe' of undefined" 相关变量是patient.name。以下是导致该问题的代码: this.filteredPatients=thi

我使用的是带角材质的Angular 5

我有一份文件清单。我得到表单中的第一个文档数据,它将由用户填写

我添加了一个自动完成字段,用于检索数据库中的患者数据。 使用它之后,我验证了我的表单,并获得了第二个文档数据,但我也遇到了一个关于自动完成字段的问题:

"ERROR TypeError: Cannot read property 'subscribe' of undefined"
相关变量是
patient.name
。以下是导致该问题的代码:

this.filteredPatients=this.myControl.valueChanges.pipe(
startWith(“”),
映射(patient=>typeof patient===“string”?patient:patient.name),//name?this.filterPatient(name):this.listPatients.slice()
);
这是我的组件HTML文件:


{{patient.lastName}
{{patient.firstName}|
né(e)le{{patient.dateNaissance}|
IPP:{{patient.IPP}}
组件TS文件:

@组件({
选择器:“应用程序多索引对话框”,
templateUrl:'indexation.multiple.component.html',
styleUrls:['indexation.multiple.component.css']
})
导出类ModalMultiIndexComponent实现OnInit,AfterViewInit{
@输入()
showViewer=true;
克林克服务:克林克服务;
列表患者:患者[]=[];
listTasksToIndex:DataTable[]=[];
wfvd_评论评论:;
myControl:FormControl=newformcontrol();
过滤患者:可观察;
病人选择:病人;
医学院:医学院;
任务索引=0;
构造函数(公共dialogRef:MatDialogRef,
@注入(MAT_DIALOG_DATA)公共数据:任意,
专用dateAdapter:dateAdapter,
私人apiService(户外服务){
log('ModalMultiIndexComponent-constructor');
this.locale='fr';
this.dateAdapter.setLocale('fr');
this.klinkServices=data.klinkServices;
this.listTasksToIndex.push(data.dataTable);
这个。getPriorities();
this.startProcess(this.taskIndex);
}
恩戈尼尼特(){
this.filteredPatients=this.myControl.valueChanges.pipe(
startWith(“”),
map(患者=>typeof患者=='string'?患者:患者名称),
map(name=>name?this.filterPatient(name):this.listPatients.slice()
);
}
ngAfterViewInit(){
//this.myControl.setValue(“”);
//this.listPatients=[];
//this.filteredPatients=新的可观察();
}
displayFnPat(患者:患者):字符串|未定义{
返回患者?患者名称:未定义;
}
filterPatient(名称:string){
返回此.listPatients.filter(患者=>
patient.name.toLowerCase().includes(name.toLowerCase());
}
获取患者(事件:任何){
让searchTerm='';
searchTerm+=event.target.value;
console.log(searchTerm);
if(searchTerm.length==2){
让成功:any={};
this.klinkservices.getPatients(searchTerm)
。然后((webScriptdata)=>{
success=webScriptdata;
this.listPatients=success.data.items;
console.log(this.listPatients);
},
msg=>{
警报(msg);
});
}
}
选择pat():void{
log(this.myControl.value.nodeRef);
console.log(this.patientChoice.nodeRef);
}
startProcess(indexElt){
//console.log(indexet);
//console.log(this.listTasksToIndex[0].dataRows.length);
if(indexert{
promiseResult=成功;
this.taskId=promiseResult.data.id;
this.documentName=promiseResult.data.description;
this.wfvd_commentaireSecretaire=promiseResult.data.properties.wfvd_commentaireSecretaire;
this.wfvd_nomService=promiseResult.data.properties.wfvd_nomService;
this.wfvd_dateDocument=promiseResult.data.properties.wfvd_dateDocument?
新表单控件(新日期(promiseResult.data.properties.wfvd\u dateDocument))
:new FormControl(new Date());
this.priorityChoice={
id:promiseResult.data.properties.bpm\u优先级,
名称:promiseResult.data.propertyLabels.bpm\u优先级
};
this.patientChoice=this.getPatientByNodeRef(promiserResult.data.properties.wfvd\u患者);
this.medecinChoice=this.getMedecinByNodeRef(promiseResult.data.properties.wfvd\u medecin);
this.originalPatientNodeRef=(promiseResult.data.properties.wfvd_patients!==null?
promiseResult.data.properties.wfvd_患者:“”);
this.originalMedecinNodeRef=(promiseResult.data.properties.wfvd_medecin!==null?
promiseResult.data.properties.wfvd_medecin:“”);
},
msg=>{
警报(msg);
});
}
getPatientByNodeRef(patientSearch:string){
return(this.listPatients.find(x=>x.nodeRef==patientSearch));
}
getMedecinByNodeRef(medecinSearch:string){
return(this.listmedicins.find(x=>x.nodeRef==medecinSearch));
}
getDocNodeId(任务ID){
让成功:any={};
this.klinkServices.getDocNodeId(taskId)
。然后((webScriptdata)=>{
success=webScriptdata;
this.docNodeId=success.docNodeId;
},
msg=>{
console.log(msg.error);
});
}
getPriorities(){
this.listPriorities=this.klinkServices.getPriorities();
}
getNextDoc(){
this.startProcess(this.taskIndex);
}
展示预览(活动){
this.showViewer=false;
如果(夏娃)
export interface Patient {
 'dateNaissance': string;
 'description': string;
 'displayPath': string;
 'firstName': string;
 'ipp': string;
 'isContainer': string;
 'lastName': string;
 'name': string;
 'nodeRef': string;
 'parentType': string;
 'selectable': string;
 'title': string;
 'type': string;
}
 if (promiseResult.data.properties.wfvd_patients) {
            this.getPatientByNodeRef(promiseResult.data.properties.wfvd_patients);
          } else {
            this.patientChoice = {} as Patient;
          }
          if (promiseResult.data.properties.wfvd_medecin) {
            this.getMedecinByNodeRef(promiseResult.data.properties.wfvd_medecin);
          } else {
            this.medecinChoice = {} as Medecin;
          }