I am using asp-net core and angular 2 a web project. I want to implement module lazy loading concept in my current application but its not working for me tried almost every solution available.
ClientApp\app\components\home\ home.routing.module.ts
const routes: Routes = [
{
path: 'home', component: HomeComponent,
children: [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full' },
{ path: 'dashboard', component: DashboardComponent }
]
}
]
export const routableComponents = [DashboardComponent]
@NgModule({
imports: [CommonModule, RouterModule.forChild(routes)],
exports: [RouterModule],
declarations: [routableComponents]
})
export class HomeRoutingModule {
}
app-routing-module.ts
const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent },
{ path: 'register-user', component: RegisterUserComponent },
{ path: 'home', loadChildren: "./components/home/home.routing.module#HomeRoutingModule" },
{ path: '**', redirectTo: 'login' }
i am getting the this error with above mentioned code
EXCEPTION: Uncaught (in promise): TypeError: webpack_require.i(...) is not a function TypeError: webpack_require.i(...) is not a function
also using this package as per suggested here
"angular2-router-loader": "0.3.4"
webpack.config.js
const sharedConfig = {
stats: { modules: false },
context: __dirname,
resolve: { extensions: ['.js', '.ts'] },
output: {
filename: '[name].js',
publicPath: '/dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
},
module: {
rules: [
{
test: /\.ts$/, include: /ClientApp/, use: ['awesome-typescript-loader?silent=true', 'angular2-template-loader',
'angular2-router-loader']
},
{ test: /\.html$/, use: 'html-loader?minimize=false' },
{ test: /\.css$/, use: ['to-string-loader', 'css-loader'] },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
]
},
plugins: [new CheckerPlugin()]
}
Please suggest what i am doing wrong.
{ path: 'recipes', loadChildren: 'app/recipes/recipes.module#RecipesModule' },notice it gives the path starting withappand doesn't have the./in the front. Try that?