Children route parameter are not set with withComponentInputBinding

Discussão em 'Angular' iniciado por user2959635, Setembro 16, 2024.

  1. user2959635

    user2959635 Guest

    In an Angular 18 application I can not have children route parameter set.

    I have a route defined as

    export const routes: Routes = [
    { path: 'test',
    children: [
    { path: ':eek:peration/:id', component: CrudComponent },
    { path: ':eek:peration', component: CrudComponent},
    { path: '', component: CrudComponent }
    ], component: TestComponent},


    and in app.config.ts

    export const appConfig: ApplicationConfig = {
    providers: [provideRouter(routes, withComponentInputBinding()),


    in test.component.html

    <a [routerLink]="['/test']">no operation</a>-
    <a [routerLink]="['/test','onlyoperation']">only operation</a>-
    <a [routerLink]="[ '/test','operationNid','123']">operation and id</a>
    <hr/>operation={{operation}} id={{id}}


    and in test.component.ts

    @Input() operation:string="";
    @Input() id:number=0;


    I expected to see the values shown by "operation={{operation}} id={{id}}", but they remain blank.

    If I define the following routes, it works as expected

    export const routes: Routes = [
    { path: 'test/:eek:peration/:id', component: TestComponent },
    { path: 'test/:eek:peration', component: TestComponent },
    { path: 'test', component: TestComponent},


    where am I wrong?

    Continue reading...

Compartilhe esta Página