/* Routes Configuration */
import { RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { ShopComponent } from './home/shop.component';
import { DataResolver } from './data-resolver';
const routes = [
{
path: 'home',
canActivate: ['canActivateservice'],
children: [
{ path: 'contact', loadChildren: './src/contact/contact.module#ContactModule' },
]
},
{ path: 'about', loadChildren: './src/about/about.module#AboutModule' },
{ path: '', component: HomeComponent }
];
export default RouterModule.forRoot(routes);
In the code snippet above, we are loading the contact module and using a canActivate guard.
import { Route, RouterModule } from '@angular/router';
import { ContactComponent } from './contact.component';
import { MapComponent } from './map.component';
import { DefaultComponent } from './default.component';
export const ContactRoutes: Route[] = [
{
path: '',
data: { id: '1', desc: 'foo' },
component: ContactComponent,
children: [
{ path: '', component: DefaultComponent },
]
}
];
export default RouterModule.forChild(ContactRoutes);
In the code above, we are passing data from this module.
canActivate(next: ActivatedRoute,state: RouterStateSnapshot) {
console.log(next)
});
}
The code snippet above shows that when we do a console.log(next), no data is seen in the 'next' object.