April 1, 2024, 8:28 a.m. | Connie Leung

DEV Community dev.to




Introduction


HostAttributeToken is a new feature in Angular 17.3.0 that injects static attributes of the host node. The decorator version of HostAttributeToken is @Attribute, and it is recommended to use it over @Input because Input triggers change detection even when the input value is static.


Before Angular 17.3.0,



<app-comp  hello='A' />

@Component({
selector: 'app-comp,
template: `<div>{{hello}}</div>`
})
export class SomeComponent {
hello: string;

constructor(@Attribute('hello) hello: string) {
this.hello = hello; // A
}
}


HostAttributeToken is an injection token that …

angular app attributes change detection feature hello host injection input introduction node token tutorial value version webdev

Information Security Engineers

@ D. E. Shaw Research | New York City

Technology Security Analyst

@ Halton Region | Oakville, Ontario, Canada

Senior Cyber Security Analyst

@ Valley Water | San Jose, CA

Senior - Penetration Tester

@ Deloitte | Madrid, España

Associate Cyber Incident Responder

@ Highmark Health | PA, Working at Home - Pennsylvania

Senior Insider Threat Analyst

@ IT Concepts Inc. | Woodlawn, Maryland, United States