I cannot comment so I will write this as an answer. Can you try this?
edit base on comment:
Since login component is in its own module (I will call it Child module). Try this:
Simply add {path: '', loadChildren: 'app/child/child.module#ChildModule'}
const appRoutes: Routes = [
{ path: '**', redirectTo: '', pathMatch: 'full' },
{ path: '', loadChildren: 'app/child/child.module#ChildModule'}
];
and in the Child Module:
imports: [
RouterModule.forChild([
{
path: '',
component: LoginComponent
}
])
]
Ideally, you would do:
Define ChildRoutingModule:
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: LoginComponent
}
])
],
exports: [
RouterModule
]
})
export class ChildRoutingModule {}
In the ChildModule:
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {LoginComponent} from './login.component';
@NgModule({
imports: [
CommonModule,
ChildRoutingModule
],
declarations: [
LoginComponent
]
})
export class ChildModule {}
In the AppRoutingModule:
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
@NgModule({
imports: [
RouterModule.forRoot([
{path: '**', redirectTo: '', pathMatch: 'full'},
{path: '', loadChildren: 'app/child/child.module#ChildModule'}
])
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
and finally in the app Module:
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';
import {AppRoutingModule} from './app-routing.module';
@NgModule({
imports: [
BrowserModule,
AppRoutingModule
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
})
export class AppModule {}
Hope this helps!