feat: add router input binding (#165) · NativeScript/angular@4afefc6 · GitHub
Skip to content

Commit 4afefc6

Browse files
authored
feat: add router input binding (#165)
* feat: add router input binding * fix: rename withComponentInputBinding to provideComponentInputBinding for consistency and don't use magic numbers
1 parent 96ffe62 commit 4afefc6

8 files changed

Lines changed: 419 additions & 1 deletion

File tree

apps/nativescript-demo-ng/src/app/app.routes.ts

Lines changed: 9 additions & 0 deletions
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component, input, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptCommonModule } from '@nativescript/angular';
3+
4+
@Component({
5+
selector: 'ns-input-binding-demo',
6+
template: `
7+
<ActionBar title="Input Binding Demo" class="action-bar"></ActionBar>
8+
<StackLayout class="p-4">
9+
<Label text="Route Input Binding Demo" class="text-2xl font-bold text-center"></Label>
10+
11+
<Label class="mt-4 text-lg font-bold" text="Route Param:"></Label>
12+
<Label class="text-base" [text]="'name = ' + name()"></Label>
13+
14+
<Label class="mt-4 text-lg font-bold" text="Query Param:"></Label>
15+
<Label class="text-base" [text]="'language = ' + language()"></Label>
16+
17+
<Label class="mt-4 text-lg font-bold" text="Resolver Data:"></Label>
18+
<Label class="text-base" [text]="'timestamp = ' + timestamp()"></Label>
19+
20+
<Label class="mt-4 text-lg font-bold" text="Static Route Data:"></Label>
21+
<Label class="text-base" [text]="'title = ' + title()"></Label>
22+
</StackLayout>
23+
`,
24+
imports: [NativeScriptCommonModule],
25+
schemas: [NO_ERRORS_SCHEMA],
26+
})
27+
export class InputBindingDemoComponent {
28+
name = input<string>();
29+
language = input<string>();
30+
timestamp = input<string>();
31+
title = input<string>();
32+
}

apps/nativescript-demo-ng/src/app/item3/items.component.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@
4444
backgroundColor="#00d2ff"
4545
class="text-white mt-2 w-full font-bold h-[50]"
4646
></Button>
47+
<Button
48+
[nsRouterLink]="['/input-binding-demo', 'Angular']"
49+
[queryParams]="{ language: 'en' }"
50+
text="Input Binding Demo"
51+
[borderRadius]="borderRadius"
52+
[fontSize]="fontSize"
53+
padding="0"
54+
backgroundColor="#4CAF50"
55+
class="text-white mt-2 w-full font-bold h-[50]"
56+
></Button>
4757
</StackLayout>
4858
<ListView row="1" [items]="items" backgroundColor="#efefef">
4959
<ng-template let-item="item">

apps/nativescript-demo-ng/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
provideNativeScriptNgZone,
55
provideNativeScriptRouter,
66
runNativeScriptAngularApp,
7+
provideComponentInputBinding,
78
} from '@nativescript/angular';
89
import { Trace, Utils, SplitView } from '@nativescript/core';
910

@@ -38,6 +39,7 @@ runNativeScriptAngularApp({
3839
providers: [
3940
provideNativeScriptHttpClient(withInterceptorsFromDi()),
4041
provideNativeScriptRouter(routes),
42+
provideComponentInputBinding(),
4143
// provideNativeScriptRouter(SPLIT_VIEW_ROUTES),
4244
ZONELESS ? provideZonelessChangeDetection() : provideNativeScriptNgZone(),
4345
],
Lines changed: 254 additions & 0 deletions

0 commit comments

Comments
 (0)