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.

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (1)

Collapse
 
fsystem profile image
Facundo Ezequiel Diaz Cappella

Great explanation

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay