Skip to content

Instantly share code, notes, and snippets.

@umutyerebakmaz
Last active May 29, 2020 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umutyerebakmaz/a56e0df10a1cb4291d0080f4f3dc8f07 to your computer and use it in GitHub Desktop.
Save umutyerebakmaz/a56e0df10a1cb4291d0080f4f3dc8f07 to your computer and use it in GitHub Desktop.
<!-- activity.vehicleId -->
<mat-form-field appearance="outline" class="full-width">
<mat-chip-list #vehicleList aria-label="Araç Seç">
<mat-chip *ngFor="let vehicle of vehicles" [selectable]="selectable" [removable]="removable"
(removed)="removeVehicle(vehicle)">
{{ vehicle.plate }}
<mat-icon matChipRemove *ngIf="removable">cancel</mat-icon>
</mat-chip>
<input placeholder="Araç Ekle..." #vehicleInput (keyup)="vehicleSearch()" [formControl]="vehicleCtrl"
[matAutocomplete]="vehicleAuto" [matChipInputFor]="vehicleList"
[matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="addOnBlur">
</mat-chip-list>
<mat-autocomplete #vehicleAuto="matAutocomplete" (optionSelected)="selectedVehicle($event)">
<mat-option *ngFor="let vehicle of vehicles$ | async" [value]="vehicle">
{{ vehicle.plate }}
</mat-option>
</mat-autocomplete>
</mat-form-field>
getVehicles() {
this.vehicles$ = this.vehiclesGQL
.watch({ plate: this.vehicleSearchKey, skip: this.skip, take: this.limit })
.valueChanges.pipe(map(result => result.data.vehicles));
}
// searches
vehicleSearch() {
this.vehicleSearchKey = this.vehicleCtrl.value || '';
console.log(this.vehicleSearchKey);
this.getVehicles();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment