Skip to content

Commit

Permalink
feat: add provideLinkedQueryParamConfig function and updated the beha…
Browse files Browse the repository at this point in the history
…vior for defaultValue
  • Loading branch information
eneajaho committed Jan 25, 2025
1 parent 212c9f4 commit abee4ce
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/src/content/docs/utilities/Injectors/linked-query-param.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ You can also set the signal to null to remove the query parameter from the URL.

These will work the same as using them on the `navigate()` method of the Router.

You can either provide the navigation extras in the options param in the `linkedQueryParam` function, or you can use the `provideLinkedQueryParamConfig` function to provide the navigation extras either in a component (recommended) or globally.

- `queryParamsHandling`

You can specify how to handle query parameters when updating the URL.
Expand Down Expand Up @@ -164,6 +166,22 @@ You can specify whether to replace the current URL in the browser's history or p
const page = linkedQueryParam('page', { replaceUrl: true });
```

#### With `provideLinkedQueryParamConfig`

In the example below, the `preserveFragment` option will be set to `true` for all the `linkedQueryParam` function usages in the component (and its children).

```ts
import { provideLinkedQueryParamConfig } from 'ngxtension/linked-query-param';

@Component({
providers: [provideLinkedQueryParamConfig({ preserveFragment: true })],
})
export class MyComponent {
readonly searchQuery = linkedQueryParam('searchQuery');
readonly page = linkedQueryParam('page');
}
```

### Examples of usage

- Usage with template driven forms & resource API
Expand Down

0 comments on commit abee4ce

Please sign in to comment.