Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70429

Use search result

$
0
0

@fc299684 wrote:

Hello how are you doing? :grin:
I have a problem, I can’t find where I should continue.

It is a SearchBar with FormControl, I need to use the result hint to fill in the value of that FormControl.

Currently I get the results that come from the service (some simulated data for testing).

I need to capture the search result and leave it to later send that information and assign it to the user.
I leave my code here:


  public vehicleBrands: Array<VehicleBrand>;
  public vehicle: Vehicle;
   public brandControl = new FormControl ('', Validators.required);


const obs = this.brandControl.valueChanges.pipe(
        filter(text => text.length > 2),
        debounceTime(350),
        distinctUntilChanged(),
        switchMap((brandFilter) => this.refDataService.getVehicleBrands(brandFilter)))
        .subscribe( resp =>  this.vehicleBrands = resp);
          
        }
<ion-header>


</ion-header>

<ion-toolbar>
    <ion-searchbar placeholder=" Search Brand " type="text " [formControl]="brandControl "></ion-searchbar>
</ion-toolbar>

<ion-content>
    <ion-list>
        <ion-item *ngFor="let brand of vehicleBrands" [value]="brand" >
            <ion-label>{{ brand.name }}</ion-label>
            

            </ion-item>
        </ion-item>
    </ion-list>
</ion-content>

Kind Regards

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70429

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>