Skip to content

Url created by routerLink can't be apply when typing it manually in address bar #62384

@olegdunkan

Description

@olegdunkan

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

No

Description


import { bootstrapApplication } from '@angular/platform-browser';

import { provideRouter, RouterLink, RouterOutlet, Routes, withComponentInputBinding } from '@angular/router';
import { ApplicationConfig, Component, Input, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';

@Component({
  selector: 'node-comp',
  standalone: true,
  imports: [RouterOutlet],
  template: `
    <div>
      <h3>Node of {{ name }}</h3>
      <router-outlet name="primary"></router-outlet>
      <router-outlet name="a"></router-outlet>
      <router-outlet name="b"></router-outlet>
    </div>
  `,
})
export class NodeComponent {
  @Input() name = '';
}

export const routes: Routes = [
  {
    path: 'a',
    component: NodeComponent,
    data: {
      name: 'a-outlet',
    },
    outlet: 'a',
  },
  {
    path: '',
    component: NodeComponent,
    children: [
      {
        path: 'b1',
        component: NodeComponent,
        data: {
          name: 'b1-path',
        },
        outlet: 'a',
      },
    ],
    data: {
      name: 'b-outlet',
    },
    outlet: 'b',
  },
];

@Component({
  selector: 'app-root',
  imports:[RouterOutlet, RouterLink],
  template: `
    <h2>App</h2>
    <router-outlet name="primary"></router-outlet>
    <router-outlet name="a"></router-outlet>
    <router-outlet name="b"></router-outlet>
    <button [routerLink]="['/', {outlets: {a:['a'], b:[{outlets: {a:['b1']}}]}} ]">Go</button>
  `,
})
export class App {
}
export const appConfig: ApplicationConfig = {
  providers: [
    provideBrowserGlobalErrorListeners(),
    provideZoneChangeDetection({ eventCoalescing: true }),
    provideRouter(routes, withComponentInputBinding()),
  ],
};

bootstrapApplication(App, appConfig);

When I click to "Go" button every is ok, we can see correct url at address bar, but when I refresh or type it manually it doesn't work.

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-rf5axciz?file=src%2Fmain.ts

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 20.0.4
Node: 24.3.0
Package Manager: npm 11.4.2
OS: darwin x64

Angular: 20.0.5
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.2000.4
@angular-devkit/core         20.0.4
@angular-devkit/schematics   20.0.4
@angular/build               20.0.4
@angular/cli                 20.0.4
@schematics/angular          20.0.4
rxjs                         7.8.2
typescript                   5.8.3
zone.js                      0.15.1

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions