• 1000 вверх, могу я узнать, в чем проблема? Я новичок в angular 9
HTML
<tr *ngFor="let item of dataSource" cdkDrag cdkDragLockAxis="y">
....
<input class="form-control" [(ngModel)]="item.code" type="text" placeholder="Code" name="Code"
matInput
[formControl]="myControl"
[matAutocomplete]="auto">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let option of filteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
... <tr>
Машинопись
import {FormControl} from '@angular/forms';
import {Observable} from 'rxjs';
import {map, startWith} from 'rxjs/operators';
...
...
dataSource = [
{
index: 1,
name: 'abc',
code: 'abc',
desc: 'abc',
qty: 1,
unit: 'abc',
price: 1.00,
tax: 'abc',
amount: 1
},
{
index: 2,
name: 'abc2',
code: 'abc2',
desc: 'abc2',
qty: 2,
unit: 'abc2',
price: 2.00,
tax: 'abc2',
amount: 2
}];
myControl = new FormControl();
options: string[] = ['One', 'Two', 'Three'];
filteredOptions: Observable<string[]>;
ngOnInit() {
this.filteredOptions = this.myControl.valueChanges
.pipe(
startWith(''),
map(value => this._filter(value))
);
}
private _filter(value: string): string[] {
const filterValue = value.toLowerCase();
return this.options.filter(option => option.toLowerCase().includes(filterValue));
}