DEV Community

akhilmdev
akhilmdev

Posted on

1

@Attribute Decorator in Angular

The @Attribute decorator returns the value of the specified attribute that attached to the selector.In some cases, This can bring a performance boost to the application.

Suppose we are having a static value, that we need to child component, we mite use @input. By doing this we are attaching some event and on every change detection cycle it will check for changes.This can affect the performance as this is static value.

For solving this issue we can use @Attribute decorator which will take value only once.Keep in mind that we won't able to pass variable, it should be passed as string.

We will inject this decorator as in the code below in the child component.

With this changes, Angular will evaluate it once.

So this is what I understandings about @Attribute decorators. If anyone else have any extra information you can comment.

keep learning.

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server 🏁

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

Top comments (1)

Collapse
 
fsystem profile image
Facundo Ezequiel Diaz Cappella

Great explanation

Dev Diairies image

User Feedback & The Pivot That Saved The Project

🔥 Check out Episode 3 of Dev Diairies, following a successful Hackathon project turned startup.

Watch full video 🎥

👋 Kindness is contagious

Explore this insightful write-up embraced by the inclusive DEV Community. Tech enthusiasts of all skill levels can contribute insights and expand our shared knowledge.

Spreading a simple "thank you" uplifts creators—let them know your thoughts in the discussion below!

At DEV, collaborative learning fuels growth and forges stronger connections. If this piece resonated with you, a brief note of thanks goes a long way.

Okay