0

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

在此处输入图像描述

4

1 回答 1

0

好吧,在索引内部,您只能打印“引导程序”中的组件。现在,app.component.html 是您的主要 html 文件,您可以在其中放置其他组件。您不能在 index.html 中执行此操作。

于 2017-07-12T11:47:28.450 回答