title: RouterModule : Cannot read property 'forRoot' of undefined
body: <p>I want to get query params from URL. So I used RouterModule to read query params. But I am getting error </p>
  
  <blockquote>
    <p>Cannot read property 'forRoot' of undefined.</p>
  </blockquote>
  
  <p>I went through similar questions but, in my case, I don't have routes.
  All other questions used <code>RouterModule.forRoot(routes)</code>. What am I doing wrong ?</p>
  
  <blockquote>
    <p>Angular 2.4.10</p>
    
    <p>Route 3.4.10</p>
  </blockquote>
  
  <p>Here is my code.
  <strong>module.js</strong></p>
  
  <pre><code>import { NgModule } from '@angular/core';
  import { BrowserModule } from '@angular/platform-browser';
  import { UpgradeModule, downgradeComponent, downgradeInjectable } from '@angular/upgrade/static';
  import { LayoutModule } from '@angular/cdk/layout';
  import { HttpModule, Http, XHRBackend, RequestOptions } from '@angular/http';
  import { RouterModule, Router } from '@angular/router';
  
  import { FlexLayoutModule } from '@angular/flex-layout';
  import { Ng2DeviceDetectorModule } from '/thinkshop/angular2plugins/ng2-device-detector/index.ts';
  
  import { ActivateAccountService } from '/thinkshop/widgets2/thinkshopapplication/activateaccount/ActivateAccountService.ts';
  import { SupportedDeviceService } '/thinkshop/widgets2/thinkshopapplication/service/supporteddeviceservice/supporteddeviceservice.ts'
  import { FormContainerComponent } '/thinkshop/widgets2/thinkshopapplication/component/formcontainer.component.ts'
  import { ActivateAccountComponent } from '/thinkshop/widgets2/thinkshopapplication/activateaccount/activateaccount.ts';
  
  
  const CLIENT_ID = { clientId: "" };
  const APP_NAME = 'web-ideolve';
  const AUTH_TOKEN = "";
  const CAN_EDIT = false;
  
  @NgModule({
    imports: [
      BrowserModule,
      UpgradeModule,
      RouterModule.forRoot(),
      FlexLayoutModule,
      Ng2DeviceDetectorModule.forRoot(),
      HttpModule,
      LayoutModule
    ],
  
    declarations: [
      FormContainerComponent,
      ActivateAccountComponent
    ],
    entryComponents: [
      FormContainerComponent,
      ActivateAccountComponent
    ],
    providers: [
      Router,
      SupportedDeviceService,
      ActivateAccountService,
  
  
      { provide: 'CLIENT_ID', useValue: CLIENT_ID },
      { provide: 'APP_NAME', useValue: APP_NAME },
      { provide: 'AUTH_TOKEN', useValue: AUTH_TOKEN },
      { provide: 'CAN_EDIT', useValue: CAN_EDIT },
  
    ],
    bootstrap: [FormContainerComponent]
  })
  
  export class AppModule {
  
    showideolvelink = false;
  
    constructor(private upgrade: UpgradeModule) {
      this.showideolvelink = true;
    }
  }
  </code></pre>
  
  <p><strong>service.ts</strong></p>
  
  <pre><code>import { Injectable, OnInit } from '@angular/core';
  import { ActivatedRoute } from '@angular/router';
  
  @Injectable()
  export class ActivateAccountService implements OnInit{
  
      emailId: string= null;
  
      constructor(private activatedRoute: ActivatedRoute) {
      }
  
      ngOnInit() : void{
          this.init();
      }
  
      init(){
          let encodedParams: any = this.activatedRoute.snapshot.params.p;
  
          if(encodedParams != null ){
              var params= JSON.parse(atob(encodedParams));
  
              this.emailId=  params.email;
          }
      }
  
      getEmailId() : string{
          return this.emailId;
      }       
  }
  </code></pre>