Skip to content
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

Confusing usage of children routes in new router #10686

Closed
ruffiem opened this issue Aug 11, 2016 · 3 comments
Closed

Confusing usage of children routes in new router #10686

ruffiem opened this issue Aug 11, 2016 · 3 comments

Comments

@ruffiem
Copy link

ruffiem commented Aug 11, 2016

I'm submitting a ... (check one with "x")

[x] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Correct me if I'm wrong but I don't get why this :

const CRISIS_ROUTES: Routes = [ 
  { path: 'crisis', component: ListCrisisComponent },
  { path: 'crisis/create', component: CreateCrisisComponent },
  { path: 'crisis/:id', component: ViewCrisisComponent },
  { path: 'crisis/edit/:id', component: EditCrisisComponent }
];

is not the same as this :

const CRISIS_ROUTES: Routes = [
  {
    path: 'crisis',
    component: ListCrisisComponent,
    children: [
      {
        path: 'create',
        component: CreateCrisisComponent
      },
      {
        path: ':id',
        component: ViewCrisisComponent
      },
      {
        path: 'edit/:id',
        component: EditCrisisComponent
      }
    ]
  }
];

While the first is working nice, the second throws a "cannot find primary outlet" error.

Expected/desired behavior

That both resolve to the same sort of routing.

What is the motivation / use case for changing the behavior?

Maintenance, readability.

Please tell us about your environment:

  • Angular version: 2.0.0-rc.5
  • Browser: [ Chrome ]
  • Language: [ TypeScript ]
@brandonroberts
Copy link
Contributor

brandonroberts commented Aug 11, 2016

This is intended behavior. If you define a level of child routing, then your ListCrisisComponent is considered a parent and needs to have a <router-outlet></router-outlet> in its template.

In the first example, they are all considered to be top level routes.

@vsavkin
Copy link
Contributor

vsavkin commented Aug 11, 2016

Closing this issue. The behavior is intentional.

@vsavkin vsavkin closed this as completed Aug 11, 2016
@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 Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants