I\'m developing a Github repo which follows the offical tutorial of Angular (Tour of Heroes). You can see all the code here.
My problem, is that I have a directive d
If you need to use the Directive
@Directive({
selector: '[appMyCommon]'
})
export class MyCommonDirective{}
everywhere you should create a new Module.
If you use the Angular CLI you can generate:
ng g module my-common
The Module:
@NgModule({
declarations: [MyCommonDirective],
exports:[MyCommonDirective]
})
export class MyCommonModule{}
Important! the exports allow you to use the Directives outside the Module.
Finally, import that Module in every Module where you need to use the Directive.
for example:
@NgModule({
imports: [MyCommonModule]
})
export class AppModule{}
Example: Plunker