I'm developing a simple page with Angular 6 and Material 6. I want to recover data from a service using the autocomplete of Material, but I don´t know how to do it well.
From the official example https://material.angular.io/components/autocomplete/overview I don't understand how to use a service to integrate it with the autocomplete.
Can anybody help me?
Thanks
well let's assume u returning ur data from the server as Objects with a structure like IyourAwesomeData and for the purpose of this example, we will use field someName to filter the data
so ur ts component should look sth like this:
and ur HTML template should look sth like this:
You just need to fill the
options
from server data as soon as the user changes the input value.In your component file, you need to handle
onInputChanged(searchStr)
, andoptions
.Finally, I found a solution to what I wanted to do! To bind a FormArray to mat-table dataSource you have to: Briefly, the example is this:
and the code: