When to use Standalone Components or Modules in Angular 14?

Standalone components are not mandatory and will never be, there is no rule when to use them. However, Angular Architects recommend to always use Standalone components at least for new components you create. They are simply more treeshakeable and less boiler. You can mix standalone components and modules also. For the mentioned recommendation of the … Read more

How to declare a pipe globally to use in different modules?

In Angular a good technique for sharing common directives, components, pipes, etc. is to use a so called shared module. Those modules declare and export common parts, to make them usable for any of your other modules. The fundamentals section of the angular documentation is a very good read about shared modules. Let’s take as … Read more

What is entryComponents in angular ngModule?

Note: EntryConponent is Deprecated from Angular 9.0.0 See the angular docs form more details. This is for dynamically added components that are added using ViewContainerRef.createComponent(). Adding them to entryComponents tells the offline template compiler to compile them and create factories for them. The components registered in route configurations are added automatically to entryComponents as well … Read more

Use component from another module

The main rule here is that: The selectors which are applicable during compilation of a component template are determined by the module that declares that component, and the transitive closure of the exports of that module’s imports. So, try to export it: @NgModule({ declarations: [TaskCardComponent], imports: [MdCardModule], exports: [TaskCardComponent] // <== export the component you … Read more

What is the difference between declarations, providers, and import in NgModule?

Angular Concepts imports makes the exported declarations of other modules available in the current module declarations are to make directives (including components and pipes) from the current module available to other directives in the current module. Selectors of directives, components or pipes are only matched against the HTML if they are declared or imported. providers … Read more