omridevk / ng-keyboard-shortcuts

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

Multiple imports to make it work #23

Closed hunzaboy closed 5 years ago

hunzaboy commented 5 years ago

Hi,

Firstly thank you for the great library.

Secondly, I have an application with multiple modules so importing it to app.module doesn't work globally.

I have to import it in every single module. Is this supposed to work like this or is this a bug?

Thanks :)

jnfaerch commented 5 years ago

FYI I have multiple component modules but the shortcuts and help modal still work globally when only in the app.module:

import { KeyboardShortcutsModule } from 'ng-keyboard-shortcuts';
imports: [ KeyboardShortcutsModule.forRoot() ]
hunzaboy commented 5 years ago

The help modal works but if i add shortcuts directive then it gives error unless I import them again in my module.

omridevk commented 5 years ago

@hunzaboy Thanks for reporting the issue. @jnfaerch thanks for the assistance here, much appreciated :)

@hunzaboy What happens when you use the ng-keyboard-shortcuts component? do you have to import the module again in each module for it to work?

Plus, is it possible for you to create a minimal example codesandbox, you can fork this base one: https://codesandbox.io/s/ngkeyboardshortcuts-example-jvbe5 and modify it to demonstrate the issue. Thanks a lot. I will try to reproduce the issue my self in the meantime and will update if I was able to. Thanks for reporting the issue.

omridevk commented 5 years ago

@hunzaboy I was not able to reproduce the issue, can you please provide a minimal example in codesandbox using this base: https://codesandbox.io/s/ngkeyboardshortcuts-example-jvbe5 Thanks a lot :)

hunzaboy commented 5 years ago

Thanks for getting back. I am currently on vacations so I will have a look again after the latest update and will reopen the ticket if necessary. Thanks.

To answer your questions, when I have multiple modules, I have to import the lib in each module, if not then I get the error of unknown directive/component in console.