mirror of https://github.com/abpframework/abp.git
3 changed files with 27 additions and 0 deletions
@ -0,0 +1,23 @@ |
|||||
|
import { Directive, ElementRef, EventEmitter, Output, OnDestroy } from '@angular/core'; |
||||
|
import { fromEvent } from 'rxjs'; |
||||
|
import { debounceTime, filter, tap } from 'rxjs/operators'; |
||||
|
import { takeUntilDestroy } from '../utils/rxjs-utils'; |
||||
|
|
||||
|
@Directive({ |
||||
|
selector: 'form[ngSubmit]', |
||||
|
}) |
||||
|
export class FormKeyupListenerDirective implements OnDestroy { |
||||
|
@Output() ngSubmit = new EventEmitter(); |
||||
|
|
||||
|
constructor(private elRef: ElementRef) { |
||||
|
fromEvent(elRef.nativeElement as HTMLElement, 'keyup') |
||||
|
.pipe( |
||||
|
debounceTime(200), |
||||
|
filter((key: KeyboardEvent) => key && key.key === 'Enter'), |
||||
|
takeUntilDestroy(this), |
||||
|
) |
||||
|
.subscribe(() => this.ngSubmit.emit()); |
||||
|
} |
||||
|
|
||||
|
ngOnDestroy(): void {} |
||||
|
} |
||||
@ -1,4 +1,5 @@ |
|||||
export * from './autofocus.directive'; |
export * from './autofocus.directive'; |
||||
export * from './ellipsis.directive'; |
export * from './ellipsis.directive'; |
||||
|
export * from './form-keyup-listener.directive'; |
||||
export * from './permission.directive'; |
export * from './permission.directive'; |
||||
export * from './visibility.directive'; |
export * from './visibility.directive'; |
||||
|
|||||
Loading…
Reference in new issue