Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
This media is not supported in your browser
VIEW IN TELEGRAM
πŸ“„ @Attribute Decorator in Angular

#angular #decorator #attribute

As you can see, when we trigger the change detection by emitting the click event, Angular is checking the value.
We can be more efficient in this case if we use the @Attribute decorator. With this change, Angular will evaluate it once and forget about it. As a general rule, I prefer the @Attribute() approach when the string is a fixed value that never changes.

import { Component, Attribute } from '@angular/core';

@Component({...})
export class ButtonComponent {

constructor(
@Attribute('type')
public type: ButtonType = 'primary'
) {
}

}

βœ… Article Link: https://netbasal.com/getting-to-know-the-attribute-decorator-in-angular-4f7c9fb61243
πŸ‘1
πŸ“„ Debounce decorator in Angular

#angular #decorator #debounce

⚠️ Third-Party Lib

Usage example:

@Component({...})
export class ExampleComponent {

@Debounce(1000)
execute(arg: unknown) {
[ ... ]
}

}

βœ… Article Link: https://blog.bitsrc.io/3-ways-to-debounce-http-requests-in-angular-c407eb165ada
❀1