Since switching to the latest builds of Angular 2 (i.e. on github, master), I get warnings as follows about all my components:
NgModule DynamicModule
This caught me out too. Significant changes in RC5 to the way that you route and bootstrap with a significant reliance on app.module.ts and @NgModule decorator. The documentation has been updated here: https://angular.io/docs/ts/latest/ and the changelog here: https://github.com/angular/angular/blob/master/CHANGELOG.md
Main changes to the routing file are changes to the import and export statements. A simple example is illustrated below which has two components, AppComponent and HomeComponent, that serves HomeComponent from index.html:
File: app.routing.ts
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home.component';
const appRoutes: Routes = [
{
path: '',
redirectTo: '/home',
pathMatch: 'full'
},
{
path: 'home',
component: HomeComponent
}
];
export const routing = RouterModule.forRoot(appRoutes);`
You then need to use an NgModule file:
File: app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { HomeComponent } from './home.component';
import { routing } from './app.routing';
@NgModule({
imports: [ BrowserModule, routing ],
declarations: [ AppComponent, HomeComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
And then you need to pull in AppModule to main.ts and bootstrap using it.
File: main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);`
This pattern does not produce the console warning message.