Browse Source

improvement(core): add debounce time input

pull/2215/head
thediaval 7 years ago
parent
commit
60f837e995
  1. 5
      npm/ng-packs/packages/core/src/lib/directives/form-submit.directive.ts

5
npm/ng-packs/packages/core/src/lib/directives/form-submit.directive.ts

@ -21,6 +21,9 @@ type Controls = { [key: string]: FormControl } | FormGroup[];
selector: 'form[ngSubmit][formGroup]', selector: 'form[ngSubmit][formGroup]',
}) })
export class FormSubmitDirective implements OnInit, OnDestroy { export class FormSubmitDirective implements OnInit, OnDestroy {
@Input()
debounce = 200;
@Input() @Input()
notValidateOnSubmit: string | boolean; notValidateOnSubmit: string | boolean;
@ -42,7 +45,7 @@ export class FormSubmitDirective implements OnInit, OnDestroy {
fromEvent(this.host.nativeElement as HTMLElement, 'keyup') fromEvent(this.host.nativeElement as HTMLElement, 'keyup')
.pipe( .pipe(
debounceTime(200), debounceTime(this.debounce),
filter((key: KeyboardEvent) => key && key.key === 'Enter'), filter((key: KeyboardEvent) => key && key.key === 'Enter'),
takeUntilDestroy(this), takeUntilDestroy(this),
) )

Loading…
Cancel
Save