Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 16: Simplify boileplate code to read route and query parameters from ActivatedRoute #504

Open
zaychenko-sergei opened this issue Dec 13, 2024 · 0 comments
Labels
refactoring Improving the internal implementation without affecting externally visible behavior

Comments

@zaychenko-sergei
Copy link
Contributor

Refactor components in the project to leverage Angular 16 new ability to inject route and query parameters as component inputs. This feature simplifies component design by directly mapping route and query parameters to component @Input properties, improving code clarity and reducing boilerplate in routing logic.

Motivation:

  • This reduces the need for manual extraction of route/query parameters in components.
  • This clearly defines component inputs and makes the relationship between the route/query parameters and the component explicit.
  • Direct input injection facilitates more predictable and testable components. Complex mocking of ActivatedRoute can be eliminated, setting inputs in tests is much easier.

TODO in this ticket:

  • Locate components that currently retrieve route or query parameters using ActivatedRoute
  • Replace manual parameter extraction in these components with @Input properties.
  • Update the routing configuration to pass the required parameters as inputs to the components (withComponentInputBinding).
  • Update unit tests for refactored components to verify the new input mechanism, get rid of older mocking of ActivatedRoute

Additional reading:

@zaychenko-sergei zaychenko-sergei added enhancement New feature or request refactoring Improving the internal implementation without affecting externally visible behavior and removed enhancement New feature or request labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Improving the internal implementation without affecting externally visible behavior
Projects
None yet
Development

No branches or pull requests

1 participant