diff --git a/apps/nativescript-demo-ng/src/app/app-routing.module.ts b/apps/nativescript-demo-ng/src/app/app-routing.module.ts index a6eeb26..2894e33 100644 --- a/apps/nativescript-demo-ng/src/app/app-routing.module.ts +++ b/apps/nativescript-demo-ng/src/app/app-routing.module.ts @@ -1,18 +1,22 @@ import { NgModule } from '@angular/core'; import { Routes } from '@angular/router'; import { NativeScriptRouterModule } from '@nativescript/angular'; - +import { dummyDataResolverTsResolver } from './input-bidings/dummy-data.resolver.ts.resolver'; import { ItemDetailComponent } from './item/item-detail.component'; import { ItemsComponent } from './item/items.component'; // import { HomeComponent } from './home/home.component'; // import { BootGuardService } from './boot-guard.service'; const routes: Routes = [ - { path: '', redirectTo: '/rootlazy', pathMatch: 'full' }, + { path: '', redirectTo: '/redirect', pathMatch: 'full' }, { path: 'items', component: ItemsComponent }, { path: 'item/:id', component: ItemDetailComponent }, { path: 'item2', loadChildren: () => import('./item2/item2.module').then((m) => m.Item2Module) }, { path: 'rootlazy', loadChildren: () => import('./item3/item3.module').then((m) => m.Item3Module) }, + { path: 'redirect', loadComponent: () => import('./input-bidings/redirect-page.component').then((c) => c.RedirectPage) }, + { path: 'bindings/:name', loadComponent: () => import('./input-bidings/input-bidings.component').then((c) => c.InputBidingsComponent), resolve: { + data: dummyDataResolverTsResolver + } }, /** * Test tab named outlets @@ -38,7 +42,9 @@ const routes: Routes = [ ]; @NgModule({ - imports: [NativeScriptRouterModule.forRoot(routes)], + imports: [NativeScriptRouterModule.forRoot(routes, { + bindToComponentInputs: true, + })], exports: [NativeScriptRouterModule], }) export class AppRoutingModule {} diff --git a/apps/nativescript-demo-ng/src/app/input-bidings/dummy-data.resolver.ts.resolver.ts b/apps/nativescript-demo-ng/src/app/input-bidings/dummy-data.resolver.ts.resolver.ts new file mode 100644 index 0000000..298cbfc --- /dev/null +++ b/apps/nativescript-demo-ng/src/app/input-bidings/dummy-data.resolver.ts.resolver.ts @@ -0,0 +1,6 @@ +import type { ResolveFn } from '@angular/router'; +import { of } from 'rxjs'; + +export const dummyDataResolverTsResolver: ResolveFn = (route, state) => { + return of(['Name1', 'Name2', "Name3"]); +}; diff --git a/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.css b/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.css new file mode 100644 index 0000000..5d4e87f --- /dev/null +++ b/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.css @@ -0,0 +1,3 @@ +:host { + display: block; +} diff --git a/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.html b/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.html new file mode 100644 index 0000000..a8dd090 --- /dev/null +++ b/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.html @@ -0,0 +1,9 @@ + + + + + @for(name of data(); track name) { + + } + + diff --git a/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.ts b/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.ts new file mode 100644 index 0000000..5dbf4e5 --- /dev/null +++ b/apps/nativescript-demo-ng/src/app/input-bidings/input-bidings.component.ts @@ -0,0 +1,28 @@ +import { ChangeDetectionStrategy, Component, inject, input, NO_ERRORS_SCHEMA } from '@angular/core'; +import { NativeScriptCommonModule, RouterExtensions } from '../../../../../packages/angular/src'; + +@Component({ + selector: 'app-input-bidings', + standalone: true, + imports: [ + NativeScriptCommonModule, + ], + templateUrl: `./input-bidings.component.html`, + styleUrl: './input-bidings.component.css', + changeDetection: ChangeDetectionStrategy.OnPush, + schemas: [NO_ERRORS_SCHEMA] +}) +export class InputBidingsComponent { + + protected readonly router = inject(RouterExtensions) + + name = input(); //Route param + + id = input(); //Query param + + data = input(); // Resolver + + navigationTo() { + this.router.navigate(['/bindings/testing2/'], { queryParams: { id: 10}}) + } + } diff --git a/apps/nativescript-demo-ng/src/app/input-bidings/redirect-page.component.ts b/apps/nativescript-demo-ng/src/app/input-bidings/redirect-page.component.ts new file mode 100644 index 0000000..8749c4e --- /dev/null +++ b/apps/nativescript-demo-ng/src/app/input-bidings/redirect-page.component.ts @@ -0,0 +1,22 @@ +import { ChangeDetectionStrategy, Component, inject, NO_ERRORS_SCHEMA } from "@angular/core" +import { NativeScriptCommonModule, NativeScriptRouterModule, RouterExtensions } from "../../../../../packages/angular/src" + +@Component({ + selector: 'app-input-bidings', + standalone: true, + imports: [ + NativeScriptCommonModule, NativeScriptRouterModule, + ], + template: `