-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set loading state when promise is set after click #12
Conversation
setTimeout(() => { | ||
this.initLoadingState(btnEl); | ||
}, 1); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced addEventListener with HostListener as the angular guide suggests.
It also fixes a memory leak, as the event listener wasn't detached when directive is destroyed.
Of course you could reach into the DOM with standard JavaScript and and attach event listeners manually. There are at least three problems with that approach:
You have to write the listeners correctly.
The code must detach the listener when the directive is destroyed to avoid memory leaks.
Talking to DOM API directly isn't a best practice.
@johannesjo could you please release a new version with all my changes? I use your module in several projects and I'd like to use the latest code :-) |
Thanks again! I release a new version shortly. |
My pleasure. If you have any kind of todo list of things you'd like to improve in your module, please share. Maybe I can help you with something. |
Loading state wasn't initialized if handleCurrentBtnOnly is true, and promise is added after click.