Skip to content Skip to sidebar Skip to footer

Angular 2 Child Routing (v3) 'cannot Read Property 'annotations' Of Undefined'

I'm trying to play around in Angular 2 and get a test app running but I'm having some problems getting the routing to work in the latest version of the router (3.0.0 alpha-7). mai

Solution 1:

Sounds like:

Similar issues:

Check for common errors:

  • Ensure you don't have / in path of your routes
  • Ensure every route has one of component, redirectTo, children
  • Ensure the components used in the routes are properly imported to the files where the routes are defined

Solution 2:

I had this error using webpack and trying to asynchronously load routes like so:

{
 path: 'password', loadChildren: () =>newPromise(resolve => {
   (requireasany).ensure([], require => {
     resolve(require('./password/password.module').PasswordModule);
   });
 })
},

Nothing wrong with the above code but then look at the module I thought I was loading:

@NgModule({
imports: [
 CommonModule,
 ...
],
declarations: [
  ...
],
providers: [
 ...
]
})
export class LockedModule {}  // wrong name !!!!

Notice the name of the module, LockedModule, it should be PasswordModule. I stumbled onto this and it took me a while to find. It's not very often I scroll to the bottom and verify the export name and the debug window gave me no indication that this was the cause.

Post a Comment for "Angular 2 Child Routing (v3) 'cannot Read Property 'annotations' Of Undefined'"