1

In Angular 16, if you are using an application without an AppModule, where should you put a global custom directive that you imported in the AppModule declarations?

For example I have a directive called hasRole that I used to add to the declarations array of the AppModule in Angular 15 to use it globally. However, I am not using an AppModule in Angular 16. Where should I declare this directive to use it globally?

Alexis
  • 816
  • 2
  • 11
  • 28

1 Answers1

0

You can migrate it into a standalone directive and directly import it into each component where it's needed.

You can learn more about standalone components, directives, and pipes in this Angular guide: https://angular.io/guide/standalone-components

Amer
  • 6,162
  • 2
  • 8
  • 34