title: Angular 2 Routing - ModuleWithProviders v NgModule
body: <p>I'm working on a MEAN project via Angular 2, and am setting up the routing for my various pages. I've seen a lot of examples that use ModuleWithProviders to do routing, rather than the angular.io example with NgModule (<a href="https://angular.io/guide/router" rel="noreferrer">https://angular.io/guide/router</a>)</p>
  
  <p>Which is the standard way of doing things? If either is acceptable, is there a performance difference between the two?</p>
  
  <p>ModuleWithProviders example:</p>
  
  <pre><code>import { ModuleWithProviders } from '@angular/core';
  import {Routes, RouterModule} from '@angular/router';
  
  import { AppComponent } from './app.component';
  import { AboutComponent } from './about/about.component';
  import { ServicesComponent } from './services/services.component';
  
  export const router: Routes = [
      { path: '', redirectTo: 'about', pathMatch: 'full'},
      { path: 'about', component: AboutComponent },
      { path: 'services', component: ServicesComponent }
  ];
  
  export const routes: ModuleWithProviders = RouterModule.forRoot(router);
  </code></pre>
  
  <p>NgModule Example:</p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import {Routes, RouterModule} from '@angular/router';
  
  import { AppComponent } from './app.component';
  import { AboutComponent } from './about/about.component';
  import { ServicesComponent } from './services/services.component';
  
  export const router: Routes = [
      { path: '', redirectTo: 'about', pathMatch: 'full'},
      { path: 'about', component: AboutComponent },
      { path: 'services', component: ServicesComponent }
  ];
  
  @NgModule({
    imports: [
      RouterModule.forRoot( router )
    ],
    exports: [
      RouterModule
    ]
  })
  
  export class AppRoutingModule {}
  </code></pre>