0
我是新與角2,我已經產生了組件使用此命令顯示內容不工作
ng generate component hello
和生成的所有文件和app.module.ts被更新。
在的index.html我加入這個
<app-hello></app-hello>
但網頁變成空白,什麼都沒有出現。
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HelloComponent } from './hello/hello.component';
@NgModule({
declarations: [
AppComponent,
HelloComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
嘗試用'bootstrap:[HelloComponent]替換'bootstrap:[AppComponent]' – yurzui
我們列出了bootstrap中的組件,告訴角度這些組件是我們的出發點。這意味着角將以特殊的方式編譯這些組件(生成主機工廠)並且將尋找滿足組件選擇器的元素。然後在這些元素裏面放置組件template.https://stackoverflow.com/questions/44077178/what-does-it-mean-to-bootstrap-an-angular-application/44077696#44077696 – yurzui
只需改變你的標籤引導程序主要組件的索引 –