Skip to content

unable to create a redirect for named outlet #33783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aquark opened this issue Nov 13, 2019 · 5 comments
Closed

unable to create a redirect for named outlet #33783

aquark opened this issue Nov 13, 2019 · 5 comments

Comments

@aquark
Copy link

aquark commented Nov 13, 2019

🐞 bug report

Affected Package

The issue is caused by package @angular/router

Is this a regression?

Unsure.

Description

I have a named router outlet which I want to default by redirecting the empty path to one of the named paths, e.g.

{ outlet: 'test', path: '', pathMatch: 'full', redirectTo: 'default' },
{ outlet: 'test', path: 'default', component: TestComponent },

This worked when the configuration was in a lazy loaded module, however moving it to the root router configuration now fails to validate. This configuration seems like it should be valid. The only workaround I could find was to use an absolute path, e.g.

{ path: 'test', pathMatch: 'full', redirectTo: '/test/(test:default)' },

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-issue-repro2-fikqg2

🔥 Exception or Error


Error: Invalid configuration of route 'test/': a componentless route without children or loadChildren cannot have a named outlet set

🌍 Your Environment

Angular Version:


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / ▄1�7 \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 8.3.17
Node: 12.4.0
OS: darwin x64
Angular: 8.2.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       
@angular-devkit/build-angular   0.802.2
@angular-devkit/core            
@angular-devkit/schematics      
@angular/cdk                    7.3.7
@angular/cli                    8.3.17
@angular/material               7.3.7
@schematics/angular             
@schematics/update              
rxjs                            6.5.3
typescript                      3.5.3
webpack                         4.38.0

Anything else relevant?
Nope.

@mduft
Copy link

mduft commented Jun 7, 2022

After updating to Angular 14, I got this error for our router configuration. It seems that this was possible all the way from Angular 9 to 13, but no longer for 14:

const ADMIN_ROUTES: Route[] = [
  {
    path: '',
    pathMatch: 'full',
    redirectTo: 'all',
  },
  {
    path: 'all',
    component: AdminShellComponent,
    children: [
      { path: '', pathMatch: 'full', redirectTo: 'general', outlet: 'admin' },
      {
        path: 'general',
        component: SettingsGeneralComponent,
        canDeactivate: [DirtyDialogGuard],
        outlet: 'admin',
      },
...

we had to replace this with:

const ADMIN_ROUTES: Route[] = [
  {
    path: '',
    pathMatch: 'full',
    redirectTo: '/admin/all/(admin:general)',
  },
  {
    path: 'all',
    component: AdminShellComponent,
    children: [
      {
        path: 'general',
        component: SettingsGeneralComponent,
        canDeactivate: [DirtyDialogGuard],
        outlet: 'admin',
      },
...

(note that the default redirect for the 'admin' panel moved from the children to the outer (main) redirect).

this works nearly as well (for us), since we're never directly navigating to /all, but always to (empty), so the default redirect will also redirect the 'admin' outlet correctly. However if a user manually navigates to the /admin/all route without outlet, this will now no longer correctly set the 'admin' outlet to 'general'...

@Talb2005
Copy link

Talb2005 commented Oct 2, 2022

Any progress with this issue?

@pixeldublu
Copy link
Contributor

pixeldublu commented Oct 30, 2022

I also discovered this issue a few days ago after upgrading. Since there was no activity I decided to create a pull request on this. (
#47921 )

Hopefully gets in soon 🤞

pixeldublu added a commit to pixeldublu/angular that referenced this issue Oct 31, 2022
fix(router): fix redirectTo on named outlets - resolves angular#33783
@mduft
Copy link

mduft commented Nov 2, 2022

Very nice, thanks. Will try this once I have time :| ;)

AndrewKushnir pushed a commit that referenced this issue Nov 4, 2022
fix(router): fix redirectTo on named outlets - resolves #33783

PR Close #47927
AndrewKushnir pushed a commit that referenced this issue Nov 4, 2022
fix(router): fix redirectTo on named outlets - resolves #33783

PR Close #47927
nouraellm pushed a commit to nouraellm/angular that referenced this issue Nov 6, 2022
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Nov 11, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@angular/animations](https://github.com/angular/angular) | dependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fanimations/14.2.9/14.2.10) |
| [@angular/common](https://github.com/angular/angular) | dependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fcommon/14.2.9/14.2.10) |
| [@angular/compiler](https://github.com/angular/angular) | dependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/14.2.9/14.2.10) |
| [@angular/compiler-cli](https://github.com/angular/angular/tree/main/packages/compiler-cli) ([source](https://github.com/angular/angular)) | devDependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/14.2.9/14.2.10) |
| [@angular/core](https://github.com/angular/angular) | dependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fcore/14.2.9/14.2.10) |
| [@angular/forms](https://github.com/angular/angular) | dependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fforms/14.2.9/14.2.10) |
| [@angular/platform-browser](https://github.com/angular/angular) | dependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/14.2.9/14.2.10) |
| [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | patch | [`14.2.9` -> `14.2.10`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/14.2.9/14.2.10) |
| [zone.js](https://github.com/angular/angular) ([changelog](https://github.com/angular/angular/blob/master/packages/zone.js/CHANGELOG.md)) | dependencies | minor | [`0.11.8` -> `0.12.0`](https://renovatebot.com/diffs/npm/zone.js/0.11.8/0.12.0) |

---

### Release Notes

<details>
<summary>angular/angular (@&#8203;angular/animations)</summary>

### [`v14.2.10`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#&#8203;14210-2022-11-09)

[Compare Source](angular/angular@14.2.9...14.2.10)

##### core

| Commit | Type | Description |
| -- | -- | -- |
| [a4312e1be5](angular/angular@a4312e1) | fix | add`  zone.js ` version `0.12.x` as a valid peer dependency ([#&#8203;48002](angular/angular#48002)) |

##### router

| Commit | Type | Description |
| -- | -- | -- |
| [db867fee77](angular/angular@db867fe) | fix | fix redirectTo on named outlets - resolves [#&#8203;33783](angular/angular#33783) ([#&#8203;47927](angular/angular#47927)) |

#### Special Thanks

Alan Agius, Albert Szekely, Andrew Scott, Doug Parker, Kristiyan Kostadinov, Markus Eckstein, Peter Scriven and abergquist

<!-- CHANGELOG SPLIT MARKER -->

</details>

<details>
<summary>angular/angular (zone.js)</summary>

### [`v0.12.0`](https://github.com/angular/angular/blob/HEAD/packages/zone.js/CHANGELOG.md#&#8203;0120-httpsgithubcomangularangularcomparezonejs-0118zonejs-0120-2022-10-27)

[Compare Source](angular/angular@zone.js-0.11.8...zone.js-0.12.0)

##### Bug Fixes

-   **zone.js:** cancel tasks only when they are scheduled or running ([#&#8203;46435](angular/angular#46435)) ([b618b5a](angular/angular@b618b5a)), closes [#&#8203;45711](angular/angular#45711)
-   **zone.js:** Fix ConsoleTask interface typo ([#&#8203;47090](angular/angular#47090)) ([91954cf](angular/angular@91954cf))

#### [0.11.8](angular/angular@zone.js-0.11.7...zone.js-0.11.8) (2022-08-08)

##### Features

-   **zone.js:** Update to the simpler Async Stack Tagging v2 API ([#&#8203;46958](angular/angular#46958)) ([f23232f](angular/angular@f23232f))

#### [0.11.7](angular/angular@zone.js-0.11.6...zone.js-0.11.7) (2022-07-20)

##### Bug Fixes

-   **zone.js:** do not invoke jasmine done callback multiple times with `waitForAsync` ([4e77c7fbf38](angular/angular@4e77c7f))

##### Features

-   **zone.js:** add AsyncStackTaggingZoneSpec implementation ([#&#8203;46693](angular/angular#46693)) ([848a009](angular/angular@848a009))
-   **zone.js:** include jasmine `describe` block name when raising unexpected task error ([de86285](angular/angular@de86285))
-   **zone.js:** include zone name when sync-test zone reports tasks ([72c2567](angular/angular@72c2567))

#### [0.11.6](angular/angular@zone.js-0.11.5...zone.js-0.11.6) (2022-06-02)

##### Bug Fixes

-   **zone.js:** check if `process` is defined when patching the `GlobalErrors.install` ([#&#8203;45392](angular/angular#45392)) ([c7bcc1b](angular/angular@c7bcc1b)), closes [#&#8203;42260](angular/angular#42260)
-   **zone.js:** in TaskTrackingZoneSpec track a periodic task until it is cancelled ([#&#8203;45391](angular/angular#45391)) ([f19b36f](angular/angular@f19b36f))
-   **zone.js:** read `Symbol.species` safely ([#&#8203;45369](angular/angular#45369)) ([e2eaac3](angular/angular@e2eaac3))
-   **zone.js:** should ignore multiple resolve call ([#&#8203;45283](angular/angular#45283)) ([aebf165](angular/angular@aebf165)), closes [#&#8203;44913](angular/angular#44913)
-   **zone.js:** swallow the error when the element callback is not patchable ([#&#8203;45400](angular/angular#45400)) ([4ea70e3](angular/angular@4ea70e3)), closes [lwc/engine-core/src/framework/base-bridge-element.ts#L180-L186](https://github.com/lwc/engine-core/src/framework/base-bridge-element.ts/issues/L180-L186) [#&#8203;42546](angular/angular#42546)

##### BREAKING CHANGES

-   **zone.js:** in TaskTrackingZoneSpec track a periodic task until it is cancelled

The breaking change is scoped only to the plugin
`zone.js/plugins/task-tracking`. If you used `TaskTrackingZoneSpec` and
checked the pending macroTasks e.g. using `(this.ngZone as any)._inner ._parent._properties.TaskTrackingZone.getTasksFor('macroTask')`, then
its behavior slightly changed for periodic macrotasks. For example,
previously the `setInterval` macrotask was no longer tracked after its
callback was executed for the first time. Now it's tracked until
the task is explicitly cancelled, e.g with `clearInterval(id)`.

#### [0.11.5](angular/angular@zone.js-0.11.4...zone.js-0.11.5) (2022-03-03)

##### Bug Fixes

-   **zone.js:** async-test should only call done once ([#&#8203;45025](angular/angular#45025)) ([dea7234](angular/angular@dea7234))
-   **zone.js:** defineProperties should also set symbol props ([#&#8203;45098](angular/angular#45098)) ([b437d12](angular/angular@b437d12)), closes [#&#8203;44095](angular/angular#44095)
-   **zone.js:** fix several test cases which trigger `done()` multiple times ([#&#8203;45025](angular/angular#45025)) ([d5565cc](angular/angular@d5565cc))
-   **zone.js:** only one listener should also re-throw an error correctly ([#&#8203;41868](angular/angular#41868)) ([299f92c](angular/angular@299f92c)), closes [#&#8203;41867](angular/angular#41867) [/github.com/angular/angular/pull/41562#issuecomment-822696973](https://github.com//github.com/angular/angular/pull/41562/issues/issuecomment-822696973)
-   **zone.js:** patch global instead of Mocha object ([#&#8203;45047](angular/angular#45047)) ([8efbdb5](angular/angular@8efbdb5)), closes [#&#8203;42834](angular/angular#42834)
-   **zone.js:** should continue to executue listeners when throw error ([#&#8203;41562](angular/angular#41562)) ([008eaf3](angular/angular@008eaf3)), closes [#&#8203;41522](angular/angular#41522)
-   **zone.js:** update several flaky cases ([#&#8203;41526](angular/angular#41526)) ([25a83eb](angular/angular@25a83eb)), closes [#&#8203;41434](angular/angular#41434)

##### Features

-   **zone.js:** add Promise.any() implementation ([#&#8203;45064](angular/angular#45064)) ([4d494d2](angular/angular@4d494d2)), closes [#&#8203;44393](angular/angular#44393)
-   **zone.js:** update electron patch to support electron/remote 14 ([#&#8203;45073](angular/angular#45073)) ([d65706a](angular/angular@d65706a)), closes [#&#8203;43346](angular/angular#43346)

#### [0.11.4](angular/angular@zone.js-0.11.3...zone.js-0.11.4) (2021-02-10)

##### Bug Fixes

-   **zone.js:** fesm2015 bundle should also be strict module. ([#&#8203;40456](angular/angular#40456)) ([f35f7c6](angular/angular@f35f7c6)), closes [#&#8203;40215](angular/angular#40215) [#&#8203;40215](angular/angular#40215)
-   **zone.js:** fix typo in zone_externs ([#&#8203;40348](angular/angular#40348)) ([8116edb](angular/angular@8116edb))
-   **zone.js:** patch child method that overrides an already patched method ([#&#8203;39850](angular/angular#39850)) ([82e3f54](angular/angular@82e3f54))
-   **zone.js:** setTimeout patch should clean tasksByHandleId cache. ([#&#8203;40586](angular/angular#40586)) ([0652b29](angular/angular@0652b29)), closes [#&#8203;40387](angular/angular#40387)
-   **zone.js:** update build tooling for latest changes in rules_nodejs ([#&#8203;40710](angular/angular#40710)) ([2827845](angular/angular@2827845))

##### Features

-   **zone.js:** monkey patches queueMicrotask() ([#&#8203;38904](angular/angular#38904)) ([27358eb](angular/angular@27358eb)), closes [#&#8203;38863](angular/angular#38863)

#### [0.11.3](angular/angular@zone.js-0.11.2...zone.js-0.11.3) (2020-10-27)

##### Bug Fixes

-   **zone.js:** remove global declaration ([#&#8203;37861](angular/angular#37861)) ([90c0772](angular/angular@90c0772)), closes [#&#8203;37531](angular/angular#37531)

#### [0.11.2](angular/angular@zone.js-0.11.0...zone.js-0.11.2) (2020-09-19)

##### Bug Fixes

-   **zone.js:** jest getRealSystemTime should return native time ([#&#8203;39127](angular/angular#39127)) ([ffc3332](angular/angular@ffc3332))
-   **zone.js:** add missing types field in package.json ([#&#8203;38585](angular/angular#38585)) ([27cc56b](angular/angular@27cc56b)), closes [#&#8203;38584](angular/angular#38584)
-   **zone.js:** defineProperty patch should not swallow error ([#&#8203;37582](angular/angular#37582)) ([45a73dd](angular/angular@45a73dd)), closes [#&#8203;37432](angular/angular#37432)
-   **zone.js:** run tests in umd format ([#&#8203;37582](angular/angular#37582)) ([40096be](angular/angular@40096be))
-   **zone.js:** should have better backward compatibilities ([#&#8203;38797](angular/angular#38797)) ([a33d630](angular/angular@a33d630)), closes [#&#8203;38561](angular/angular#38561) [#&#8203;38669](angular/angular#38669)
-   **zone.js:** should invoke xhr send task when no response error occurs ([#&#8203;38836](angular/angular#38836)) ([d92a0dd](angular/angular@d92a0dd)), closes [#&#8203;38795](angular/angular#38795)
-   **zone.js:** zone.js toString patch should check typeof Promise is function ([#&#8203;38350](angular/angular#38350)) ([18e474f](angular/angular@18e474f)), closes [#&#8203;38361](angular/angular#38361)

##### Features

-   **zone.js:** add jest fakeTimers support ([#&#8203;39016](angular/angular#39016)) ([82d54fe](angular/angular@82d54fe)), closes [#&#8203;38851](angular/angular#38851)

##### Refactor

-   **zone.js:** refactor(zone.js): rename several internal apis in fake async zone spec ([#&#8203;39127](angular/angular#39127)) ([8a68669](angular/angular@8a68669))

##### Build

-   **zone.js:** build(zone.js): zone.js should output esm format for fesm2015 bundles ([#&#8203;39203](angular/angular#39203)) ([822b838](angular/angular@822b838))

##### BREAKING CHANGES

-   **zone.js:** ZoneJS no longer swallows errors produced by `Object.defineProperty` calls.

Prior to this change, ZoneJS monkey patched `Object.defineProperty` and if there is an error
(such as the property is not configurable or not writable) the patched logic swallowed it
and only console.log was produced. This behavior used to hide real errors,
so the logic is now updated to trigger original errors (if any). One exception
where the patch remains in place is `document.registerElement`
(to allow smooth transition for code/polyfills that rely on old behavior in legacy browsers).
If your code relies on the old behavior (where errors were not thrown before),
you may need to update the logic to handle the errors that are no longer masked by ZoneJS patch.

#### [0.11.1](angular/angular@zone.js-0.11.0...zone.js-0.11.1) (2020-08-19)

##### Bug Fixes

-   **zone.js:** zone.js package.json should not include files/directories field ([#&#8203;38528](angular/angular#38528)) ([6b662d1](angular/angular@6b662d1)), closes [#&#8203;38526](angular/angular#38526) [#&#8203;38516](angular/angular#38516) [#&#8203;38513](angular/angular#38513)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♄1�7 **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired.

---

 - [x] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4yMC4wIiwidXBkYXRlZEluVmVyIjoiMzQuMjEuNCJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1632
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 5, 2022
trekladyone pushed a commit to trekladyone/angular that referenced this issue Feb 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants