显示模板的内容不起作用

时间:2017-07-12 11:29:15

标签: angular angular-templatecache

我是角度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 { }

enter image description here

1 个答案:

答案 0 :(得分:0)

嗯,在索引内部,您只能打印'bootstrap'中的组件。现在,app.component.html是您的主要html文件,您可以在其中放置其他组件。你不能在index.html中这样做。