我正在尝试将“(onLocationSelected)”返回的“ $ event”作为参数发送给(更改)“ searchInputChanged”函数。关于如何执行此操作的任何想法或替代方法?谢谢] 1
注意:“ onAutoComplete”是“ matGoogleMapsAutocomplete”依赖项的一部分。
<input matInput
matGoogleMapsAutocomplete
country="PR"
placeholder="Search for location" type="address"
formControlName="firstCtrl"
(onAutocompleteSelected)="onAutocompleteSelected($event)"
(onLocationSelected)="onLocationSelected($event)"
(change)="searchInputChanged(onLocationSelected $event)"
required>
答案 0 :(得分:1)
在onAutocompleteSelected方法中,将事件的值保存到组件中的属性,然后让searchInputChanged访问该属性。
在您的组件中。...
onAutocompleteSelected(event) {
// do whatever
this.autocompleteEvent = event
}
searchInputChanged() {
// use this.autocompleteEvent instead of passing a parameter
}