omridevk / ng-keyboard-shortcuts

Dead Simple Keyboard Shortcuts Management for Angular
https://ng-keyboard-shortcuts.vercel.app/
147 stars 34 forks source link

Project description for getting started doesn't match the real possible usage #7

Closed BlindDespair closed 5 years ago

BlindDespair commented 6 years ago

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.

mselerin commented 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.

omridevk commented 5 years ago

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.

omridevk commented 5 years ago

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.

omridevk commented 5 years ago

Please see the latest release: https://www.npmjs.com/package/ng-keyboard-shortcuts/v/7.0.3