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.

Jetbrains image

Build Secure, Ship Fast

Discover best practices to secure CI/CD without slowing down your pipeline.

Read more

Top comments (1)

Collapse
 
fsystem profile image
Facundo Ezequiel Diaz Cappella

Great explanation

Jetbrains image

Is Your CI/CD Server a Prime Target for Attack?

57% of organizations have suffered from a security incident related to DevOps toolchain exposures. It makes sense—CI/CD servers have access to source code, a highly valuable asset. Is yours secure? Check out nine practical tips to protect your CI/CD.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay