Angular · Middle · Question 32 of 75

What does withComponentInputBinding() enable?

provideRouter(routes, withComponentInputBinding());
// route: users/:id
export class UserPage {
  id = input.required<string>();
}

Explanation

Instead of injecting ActivatedRoute and subscribing to paramMap, the component simply declares an input. It updates when you navigate between /users/1 and /users/2 while staying on the same component.

Further reading

Problem with a question

Angular · Middle · question 32

Test yourself

Take the Angular · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz