ngx-async-click
v2.1.1
Published
Async click - preventing multiple clicks by condition (e.g. waiting for coming back a response from the backend)
Downloads
17
Maintainers
Readme
Angular async click directive
Installation
Use this following command to install:
npm i ngx-async-click
Usage
Version <1.1.0
import { AsyncClickModule} from 'ngx-async-click';
@NgModule({
declarations: [AppComponent],
imports: [AsyncClickModule],
bootstrap: [AppComponent]
})
export class AppModule {}
Version >=1.1.0 (Implemented standalone directive)
import { AsyncClickDirective} from 'ngx-async-click';
@NgModule({
declarations: [AppComponent],
imports: [AsyncClickDirective],
bootstrap: [AppComponent]
})
export class AppModule {}
Using
[ngxAsyncClick]="methodName.bind(this, [args])"
for example
In the HTML template
<button [ngxAsyncClick]="clickWithoutArguments.bind(this)">
Click me (without arguments)
</button>
<button [ngxAsyncClick]="clickWithoutArguments.bind(this, 'test')">
Click me (with arguments)
</button>
In the .ts file:
clickWithoutArguments() {
//
return of(1).pipe(delay(1000));
}
clickWithArguments(args: any[]) {
//
return of(1).pipe(delay(1000));
}