π Angular HostAttributeToken: the new way to inject attributes
#angular #attribute #HostAttributeToken
β Article link
#angular #attribute #HostAttributeToken
By creating an input, you are instructing Angular to create a binding to that property and check it during each change detection cycle. That is really excessive, you only need that property to be checked once during component initialization. π€― To make this more performant you can instead inject the host-element attribute in the constructor thanks to the Attribute decorator
Since the release of Angular 14 there is now a cleaner approach to inject providers without using the constructor class: the inject() function. Up until now, this inject() function allowed to inject easily components, directives and pipes, but it was missing a method to inject host attributes. And thatβs precisely why the HostAttributeToken class was introduced
β Article link
π€ Replacing Static Inputs with the Host Attribute Token
#angular #decorator #Attribute #HostAttributeToken
π© > Angular 17
β Article link
#angular #decorator #Attribute #HostAttributeToken
π© > Angular 17
β Article link
π1