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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using bracketing notation in route object is not working #28038

Closed
Mommoo opened this Issue Jan 10, 2019 · 2 comments

Comments

Projects
None yet
4 participants
@Mommoo
Copy link

Mommoo commented Jan 10, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/....

I do not know well, but I think it's probably caused by @angular/router

Is this a regression?

no

Description

i have declared routes array for component routing.
the specific route object in routes array have used resolve key for using resolve guard
the problem is that after i have declared resolve's resolver key using by literal string, when i tried compile it is okay well played, but using by bracketing notation, throw the following error.

Error in Cannot read property 'loadChildren' of undefined

after i get this error, if i try compile again, it is well done

馃敩 Minimal Reproduction

const data2 = 'data2';
const routes: Route = [
  {
    path: 'main', component: MainComponent, children: [
      {
          path: 'children',
          component: SubComponent,
          resolve: {
             'data': DataResolver          // this way is well compiled
          }
      },
     {
          path: 'children2',
          component: SubComponent2,
          resolve: {
             [data2]: DataResolver2          // this way (javascript bracketing notation) isn't compile when first 
          }
      },
    ]
  }
]

馃敟 Exception or Error




Error in Cannot read property 'loadChildren' of undefined

馃實 Your Environment

Angular Version:




@angular-devkit/architect         0.12.1
@angular-devkit/build-angular     0.12.1
@angular-devkit/build-optimizer   0.12.1
@angular-devkit/build-webpack     0.12.1
@angular-devkit/core              7.2.1
@angular-devkit/schematics        7.2.1
@angular/cli                      7.2.1
@ngtools/webpack                  7.2.1
@schematics/angular               7.2.1
@schematics/update                0.12.1
rxjs                              6.3.3
typescript                        3.2.2
webpack                           4.23.1

Anything else relevant?

@ocombe ocombe added comp: router and removed comp: router labels Jan 14, 2019

@ngbot ngbot bot added this to the needsTriage milestone Jan 14, 2019

@jasonaden

This comment has been minimized.

Copy link
Contributor

jasonaden commented Jan 15, 2019

Assigning this to compiler to comment on this issue. I believe this is working as intended, though the error message could be much clearer.

@jasonaden

This comment has been minimized.

Copy link
Contributor

jasonaden commented Jan 15, 2019

Having just talked to the compiler team, this is currently expected behavior. However, it should be fixed with Ivy when released in a future version of Angular.

The issue is the current AOT compiler doesn't understand how to handle the dynamic nature of this code. It's valid JavaScript, but cannot be compiled ahead of time. This limitation will be lifted with Ivy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment