我遇到使用anglular-cli生成組件的問題ng-cli不會將全新創建的組件添加到應用程序模塊中:ng-cli不會將組件添加到應用程序模塊
$ 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.
我沒有移動任何文件。該項目結構是默認的。該src\app\app.module.ts
存在,並且具有以下內容:
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 {
}
一切看起來OK。
@Kinduser這簡直是命令行提示符 – zhekaus
@Kinduser但在哪裏呢?我希望我知道什麼東西發電機是基於當他尋找應用程序模塊... – zhekaus
C:\ webProj \ EngMe \ web_engme – zhekaus