@opahopa wrote:
greetings.
i have a simple directive like@Directive({ selector: '[auth-protected-click]' }) export class AuthProtectedClickDirective { constructor() { console.log('fgfgfgfgfgfgfg') } @HostListener('click', ['$event']) onClick($event){ console.info('clicked: ' + $event); } }
How can i declare it in app.module.ts to make it accessible globally?
tried:
- declare it as module
@NgModule({ declarations: [ AuthProtectedClickDirective, ], exports: [ AuthProtectedClickDirective ] }) export class AuthProtectedClickDirectiveModule {}
and input in app.module.
@NgModule
=>imports
. this doesn’t throw any errors, but directive isn’t working (not initialized).
- input in app.module.
@NgModule
=>decralations
(not as module, but asAuthProtectedClickDirective
). Result is the same - no errors and not initialized.The only way i can use it is adding a dependency to this directive / it’s module directly in the
*page*.module
, which i don’t really want to do because planning to use it in multiple pages.
Posts: 1
Participants: 1