withComponentInputBinding() bind path params, query params, matrix params và route data vào component inputs có cùng tên.
Ví dụ:
typescript
bootstrapApplication(AppComponent, {
providers: [provideRouter(routes, withComponentInputBinding())],
})
@Component({ template: "User {{ id() }}" })
export class UserPage {
id = input.required<string>()
}Cách này làm component dễ test hơn và giảm coupling với ActivatedRoute.
withComponentInputBinding() binds path params, query params, matrix params and route data into component inputs with matching names.
Example:
typescript
bootstrapApplication(AppComponent, {
providers: [provideRouter(routes, withComponentInputBinding())],
})
@Component({ template: "User {{ id() }}" })
export class UserPage {
id = input.required<string>()
}This makes components easier to test and less coupled to ActivatedRoute.