Jaime Ginorio
Jaime Ginorio

Reputation: 153

How to send a different '$event' as an argument?

I'm trying to send the "$event" that '(onLocationSelected)' returns as an argument in the 'searchInputChanged' function on (change). Any idea on how to do this, or an alternative? Thanks![I'm trying to do something like this]1

Note: 'onAutoComplete' is part of the 'matGoogleMapsAutocomplete' dependencie.

            <input matInput 
                matGoogleMapsAutocomplete 
                country="PR" 
                placeholder="Search for location" type="address"
                formControlName="firstCtrl"
                (onAutocompleteSelected)="onAutocompleteSelected($event)"
                (onLocationSelected)="onLocationSelected($event)"
                (change)="searchInputChanged(onLocationSelected $event)"
                required>

Upvotes: 0

Views: 124

Answers (1)

Tzannetos Philippakos
Tzannetos Philippakos

Reputation: 489

in your onAutocompleteSelected method, save the value of your event to a property in your component, then have searchInputChanged access that property.

in your component....

onAutocompleteSelected(event) {
    // do whatever
    this.autocompleteEvent = event
}

searchInputChanged() {
    // use this.autocompleteEvent instead of passing a parameter
}

Upvotes: 2

Related Questions