I'm encountering an issue with the latest Angular 2 RC5 router (router version is RC1).
Below is the error log from the dev console:
EXCEPTION: Error in /templates/app.component.html:2:0
ORIGINAL EXCEPTION: No provider for Router!
This is how my app.modules.ts file looks like:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { AppComponent } from './components/app.component';
import { routing } from './app.routes';
@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, RouterModule, FormsModule, HttpModule, routing],
bootstrap: [AppComponent],
})
export class AppModule {}
Here's my boot.ts file content:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
The contents of my app.routes.ts file...
import { Routes, RouterModule } from '@angular/router';
// Components
import { HomeComponent } from './components/home.component';
const routes: Routes = [
// Root
{ path: '/', name: 'Home', component: HomeComponent, useAsDefault: true},
];
// - Updated Export
export const routing = RouterModule.forRoot(routes);
...and finally, my app.component.ts file:
import { Component, ViewContainerRef } from '@angular/core';
@Component({
selector: 'app',
templateUrl: '/templates/app.component.html'
})
export class AppComponent {
viewContainerRef: any;
public constructor(viewContainerRef:ViewContainerRef) {
// A small hack to catch application root view container ref
this.viewContainerRef = viewContainerRef;
}
}
Could you point out what might be missing here?