Skip to content

docs: add matrix parameters docs and examples#64459

Closed
SkyZeroZx wants to merge 1 commit intoangular:mainfrom
SkyZeroZx:docs/router-params
Closed

docs: add matrix parameters docs and examples#64459
SkyZeroZx wants to merge 1 commit intoangular:mainfrom
SkyZeroZx:docs/router-params

Conversation

@SkyZeroZx
Copy link
Contributor

@SkyZeroZx SkyZeroZx commented Oct 16, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #64451

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove pullapprove bot requested a review from kirjs October 16, 2025 04:13
@angular-robot angular-robot bot added the area: docs Related to the documentation label Oct 16, 2025
@ngbot ngbot bot added this to the Backlog milestone Oct 16, 2025
@JeanMeche JeanMeche requested a review from atscott October 16, 2025 08:50
Comment on lines +200 to +220
You can access matrix parameters through `route.params`, the same observable used for route parameters:

```ts
import { Component, inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

@Component(/* ... */)
export class SalesAwesome {
private route = inject(ActivatedRoute);

constructor() {
// Access matrix parameters via params
this.route.params.subscribe((params) => {
const openModal = params['openModal'];
if (openModal === 'true') {
// Open modal logic
}
});
}
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably isn't the best example and give the false impression that's the only why access their value.
Matrix params are present in any route object and they're also binded to inputs when you have withComponentInputBinding()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

| **Syntax** | `;key=value` | `?key=value` |
| **Multiple values** | `;key=val1;key=val2` | `?key=val1&key=val2` |
| **Access method** | `route.params` or `input` | `route.queryParams` |
| **Requires definition** | No | No |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| **Requires definition** | No | No |

I think this is kind of confusing. Better to just omit it

| Feature | Matrix Parameters | Query Parameters |
| :---------------------- | :------------------------ | :------------------- |
| **Syntax** | `;key=value` | `?key=value` |
| **Multiple values** | `;key=val1;key=val2` | `?key=val1&key=val2` |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| **Multiple values** | `;key=val1;key=val2` | `?key=val1&key=val2` |

Is this necessary to mention? While true, I don't think this information is super relevant to almost anyone. Also, this really depends on the UrlSerializer, which may be configured to handle multiple values differently


NOTE: Component input binding requires configuring the router with `withComponentInputBinding` in your router configuration.

**Key differences between matrix and query parameters:**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this section is at all necessary. It's all covered above in the example as well as the setup description:

this.router.navigate(['/awesome-products', { view: 'grid', filter: 'new' }]);
// Results in URL: /awesome-products;view=grid;filter=new

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, removed the section, I agree it seems somewhat redundant with the examples previously provided.

Comment on lines +219 to +230
**Using component input binding**

```ts
import { Component, Input } from '@angular/core';

@Component(/* ... */)
export class AwesomeProducts {
view = input.required<string>() // Automatically bound to matrix parameter
filter = input.required<string>()
}
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than writing this as an example, maybe just make a quick mention of withComponentInputBinding with something like "Matrix parameters are also bound to inputs when using the withComponentInputBinding feature"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of this way to replace the example with a note?
NOTE: Matrix parameters are also bound to component inputs when using the withComponentInputBinding feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that works. Maybe start with "Alternatively, ..." or "As an alternative to using ActivatedRoute, ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Oct 16, 2025
@JeanMeche JeanMeche removed the request for review from kirjs October 16, 2025 22:07
@thePunderWoman
Copy link
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Nov 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: docs Related to the documentation target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants