Display content of template doesn't work

191 Views Asked by At

I'm new with angular 2 , I have generated a component with this command

ng generate component hello

and all files are generated and app.module.ts is updated.

in the index.html I have added this

<app-hello></app-hello>

but the web page become blank, nothing appear.

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

There are 1 best solutions below

0
elzoy On

Well, inside index you can print only the component you have in 'bootstrap'. Now, app.component.html is your main html file where you can put other components. You can't do this in index.html.