在 Angular 2 中使用 ag-grid 中筛选字段的值

Use value of the filter field in ag-grid in Angular 2

我正在用 ag 网格做一个项目。但我想在过滤字段中获取用户的输入文本。我需要来自用户过滤器的输入来进行 http 调用。我在网站上搜索但找不到答案。

假设您为此使用 Angular 2 个组件,请查看示例项目中的 PartialMatchFilterComponent

@Component({
    selector: 'filter-cell',
    template: `
        Filter: <input style="height: 10px" #input (ngModelChange)="onChange($event)" [ngModel]="text">
    `
})
class PartialMatchFilterComponent implements AgFilterComponent {
... rest of the class

在 onChange 方法中,您可以在用户输入时触发您的请求(您可能想在此处添加某种反跳):

onChange(newValue):void {
    if (this.text !== newValue) {
        this.text = newValue;
        ... fire off your http request here ...
        this.params.filterChangedCallback();
    }
}