title: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'layout' in Angular
body: <p>I am making a normal login with username and password admin &amp; admin.In login component navigate to layout.But i am getting an error like "core.js:1448 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'layout'".please help me..</p>
  
  <p>app.routing.module.ts</p>
  
  <pre><code>import {NgModule}     from '@angular/core';
  import {RouterModule} from '@angular/router';
  
  
  @NgModule({
      imports: [
          RouterModule.forRoot([
              {path: '', redirectTo: '/login', pathMatch: 'full'},
              {path: 'login', loadChildren: 'app/login/login.module#LoginModule'}
  
          ])
      ],
      exports: [
          RouterModule
      ]
  })
  export class AppRoutingModule {
  }
  </code></pre>
  
  <p>my login.component.ts is</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { Router, ActivatedRoute } from '@angular/router';
  
  import { AuthenticationService } from '../../services/authentication.service';
  
  @Component({
    selector: 'app-login',
    templateUrl: './login.component.html',
    styleUrls: ['./login.component.css']
  })
  export class LoginComponent implements OnInit {
  
    username:string;
    password:string;
  
    constructor(
  
      public authService: AuthenticationService,
      private route: ActivatedRoute,
      private router: Router) { }
  
    ngOnInit() {
  
    }
  
    login(){
      if(this.authService.login(this.username, this.password)){
        this.router.navigate(['/layout']);
      }
    }
  }
  </code></pre>
  
  <p>my login.routing.module.ts is</p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { Routes, RouterModule } from '@angular/router';
  import { LoginComponent } from './login/login.component';
  import { LayoutComponent } from '../layout/layout/layout.component';
  import { LayoutRoutingModule } from '../layout/layout-routing.module';
  
  const routes: Routes = [
    { path: '', component: LoginComponent },
    { path: 'layout', component: LayoutComponent }
  
  
  
  
  ];
  @NgModule({
  imports: [RouterModule.forChild(routes)],
  
    exports: [RouterModule]
  })
  export class LoginRoutingModule { }
  </code></pre>