![](/img/trans.png)
[英]Hot to call a function inside a child component.ts from a parent component.ts in Angular
[英]How to call function in href inside component.ts in angular 11
我有这个function过滤医院过滤医院。 然后我有一个 infoWindow 来显示信息。 单击href时,我想调用此function
filterHospitals() {
this.hospitals = this.filterByValue(this.datasource, this.filterValue);
this.total = this.hospitals.length;
this.deleteMarkers();
this.populateMapMarker();
}
filterByValue(items: Hospital[], filter: string) {
return items.filter((o) =>
Object.keys(o).some((k) => {
if (k === 'facilityName' || k === 'facilityCategory' || k === 'clusterFacility' || k === 'stateDesc') {
return o[k].toLowerCase().includes(filter.toLowerCase());
}
return null;
})
);
}
marker.addListener('click', () => {
let infoWindowContent =
'<a href="filterHospitals()"><strong>' +
this.camelize(this.hospitals[i].facilityName) +
'</strong></a><br/>' +
}
单击href时如何将参数传递到function?
marker.addListener('click', () => {
let infoWindowContent =
'<a href="filterHospitals(facility.getAttribute(\'id\'))"
id="'+this.hospitals[i].id+'" #facility><strong>' +
this.camelize(this.hospitals[i].facilityName) +
'</strong></a><br/>' +
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.