Skip to content

Commit

Permalink
fix(filter): fix ngModal deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa committed Jun 12, 2018
1 parent 10111e2 commit e00c77f
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { distinctUntilChanged, debounceTime, skip } from 'rxjs/operators';
import { debounceTime, distinctUntilChanged, skip } from 'rxjs/operators';

import { DefaultFilter } from './default-filter';

@Component({
selector: 'input-filter',
template: `
<input [(ngModel)]="query"
[ngClass]="inputClass"
[formControl]="inputControl"
class="form-control"
type="text"
placeholder="{{ column.title }}" />
<input
[ngClass]="inputClass"
[formControl]="inputControl"
class="form-control"
type="text"
placeholder="{{ column.title }}"/>
`,
})
export class InputFilterComponent extends DefaultFilter implements OnInit {
Expand All @@ -24,12 +24,18 @@ export class InputFilterComponent extends DefaultFilter implements OnInit {
}

ngOnInit() {
if (this.query) {
this.inputControl.setValue(this.query);
}
this.inputControl.valueChanges
.pipe(
skip(1),
distinctUntilChanged(),
debounceTime(this.delay)
debounceTime(this.delay),
)
.subscribe((value: string) => this.setFilter());
.subscribe((value: string) => {
this.query = this.inputControl.value;
this.setFilter();
});
}
}

0 comments on commit e00c77f

Please sign in to comment.