I’ve encountered a problem with a component generation using anglular-cli ng-cli doesn’t add the brand-new created component to the app module:
$ ng g component Try
installing component
create src\app\try\try.component.css
create src\app\try\try.component.html
create src\app\try\try.component.spec.ts
create src\app\try\try.component.ts
update src\app\app.module.ts
No app module found. Please add your new class to your component.
I didn’t move any file. The project structure is default. The src\app\app.module.ts
exists and has the following content:
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {RouterModule} from '@angular/router';
import {AppComponent} from './app.component';
import {ROUTES} from "./app.routes";
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
RouterModule.forRoot(ROUTES)
],
declarations: [
AppComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {
}
Everything looks like ok.
ng
from this folder. it won't work otherwise at all.