Thursday, February 15, 2024

Standalone Components in Angular

Standalone Components in Angular

A standalone component is a type of component that doesn’t belong to any specific Angular module.Before Angular version 14, when you created a component, you typically had to include it in the declaration array of a module; otherwise, Angular would throw an error during compilation.Standalone components are independent units that can be instantiated and used anywhere within an Angular application, regardless of the module structure. Standalone components can be useful for creating reusable UI elements or utility functions that are not specific to any module.

In this post, we'll explore standalone components in Angular and how to create them with a detailed example.

Creating a Standalone Component

First, make sure you're using Angular version 14. To create a component on its own, use the --standalone option with the command ng generate component.

ng g c component_name  --standalone

Sunday, February 4, 2024

Decorators in Angular

Decorators in Angular

There are several important concepts in Angular, and Decorators are an important concept to learn when you are working Angular. Decorators in Angular are a powerful and essential feature used to enhance and modify the behavior of classes, methods, and properties. Through this post we will learn about decorators, its types and how it is being used in real time applications.

What are Decorators?

Decorators are functions that are invoked with a prefixed @ symbol.Basically, a decorator provides configuration metadata that determines how the component, class or a function should be processed, instantiated and used at runtime.Decorators are applied to classes, class properties, and class methods using the following syntax:

@DecoratorName(arguments)

Angular comes with several built-in decorators, and you can also create custom decorators to extend or modify the behavior of your application.

^ Scroll to Top