我正在用 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();
}
}
关于angular - 在 Angular 2 的 ag-grid 中使用过滤器字段的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40721175/