Or using CLI :
ng generate component server
server.component.ts
import { Component, OnInit } from '@angular/core'; @Component({ selector: 'app-server', templateUrl: './server.component.html', styleUrls: ['./server.component.css'] }) export class ServerComponent implements OnInit { constructor() { } ngOnInit() { } }
app.module.ts
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { ServerComponent } from './server/server.component'; @NgModule({ declarations: [ AppComponent, ServerComponent ], imports: [ BrowserModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
app.component.html
<div>Hello World</div> <app-server></app-server>
References
https://github.com/mhdr/AngularSamples/tree/master/002/my-app