Skip to content

feat: add router input binding#165

Open
edusperoni wants to merge 2 commits into
mainfrom
feat/input-binding
Open

feat: add router input binding#165
edusperoni wants to merge 2 commits into
mainfrom
feat/input-binding

Conversation

@edusperoni
Copy link
Copy Markdown
Collaborator

PR Checklist

This adds support to angular component input binding

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds support for Angular-style “bind route params/data to component inputs” when navigating through NativeScript’s PageRouterOutlet, plus a demo screen and unit tests in the demo app.

Changes:

  • Introduces RoutedComponentInputBinder and wiring in PageRouterOutlet to push merged queryParams/params/data into component inputs via ComponentRef.setInput.
  • Adds router-module helpers to register the binder (standalone provider + opt-in via router config / feature detection).
  • Adds demo route/UI and a Jasmine spec suite covering binding behavior and edge cases.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/angular/src/lib/legacy/router/router.module.ts Adds binder provider registration helpers and attempts to auto-enable when Angular component-input-binding feature is present.
packages/angular/src/lib/legacy/router/router-component-input-binder.ts New binder service that subscribes to route observables and sets component inputs based on merged route state.
packages/angular/src/lib/legacy/router/page-router-outlet.ts Integrates the binder into outlet lifecycle (bind on activation, unsubscribe on detach/deactivate/destroy).
apps/nativescript-demo-ng/src/tests/router-component-input-binder.spec.ts New unit tests validating binding precedence, query param opt-out, unmatched input behavior, and resubscription/unsubscribe logic.
apps/nativescript-demo-ng/src/main.ts Enables the feature in the demo app via withComponentInputBinding().
apps/nativescript-demo-ng/src/app/item3/items.component.html Adds navigation button to the new input-binding demo route.
apps/nativescript-demo-ng/src/app/input-binding-demo/input-binding-demo.component.ts New demo component displaying bound param/query/data/resolver values (signal inputs).
apps/nativescript-demo-ng/src/app/app.routes.ts Adds a demo route with param, static data, and resolver data.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/angular/src/lib/legacy/router/router.module.ts Outdated
Comment thread packages/angular/src/lib/legacy/router/router.module.ts
… for consistency and don't use magic numbers
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment on lines +46 to +47
const COMPONENT_INPUT_BINDING_FEATURE_KIND = (angularWithComponentInputBinding() as any).ɵkind;

Comment on lines +48 to +54
function inputBinderProviders(options: ComponentInputBindingOptions = {}): Provider[] {
return [{ provide: INPUT_BINDER, useFactory: () => new RoutedComponentInputBinder(options) }];
}

export function provideComponentInputBinding(options: ComponentInputBindingOptions = {}): Provider[] {
return inputBinderProviders(options);
}
private outletSeenKeys = new Map<PageRouterOutlet, Set<string>>();

constructor(private options: ComponentInputBindingOptions) {
this.options.queryParams ??= true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants