Closed BlindDespair closed 5 years ago
As described in the README, the service could be provided directly inside a component like this :
@Component({
selector: 'demo-component',
template: "<h2> new component </h2>"
providers: [ KeyboardShortcutsService ]
})
The main advantage is that the service will only live with the current component and when the component is destroyed, the shortcuts disappear as well.
Thanks for the feedback, and sorry for the delay, I will fix the service, but I have yet decided which way to go, I will make a PR soon so you guys can review and let me know if the change fits your needs.
Thanks.
Again apologies for the delay, I am about to release a new version without a service and only components, the documentation will be updated accordingly, and all breaking changes will be noted. The version will include a much safer way for cleanup with relatively same API.
Please see the latest release: https://www.npmjs.com/package/ng-keyboard-shortcuts/v/7.0.3
In your ng-keyboard-shortcuts.module.ts you don't have the service provided, therefore importing module does nothing, because injector still complains that there is no provider for KeyboardShortcutsService. I can provide it in my app.module as workaround but otherwise would be nice to have it matching guide.