How to create nested component in Angular 2

First creat a file with nested.component.ts

 
import { Component} from '@angular/core';
@Component({
  selector: 'nested',
  template: '<h1>Nested World</h1>'
})

export class NestedComponent { }

app.componenet.ts

 

import { Component } from '@angular/core';
@Component({
  selector: 'my-app',
  template: '<h1>Hello World</h1>
<nested></nested>',


})
export class AppComponent { }
 

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }   from './app.component';
import { NestedComponent } from './nested.component';

@NgModule({
  imports:      [ BrowserModule ],
  declarations: [ AppComponent,NestedComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

You can download the angulras 2 files from this link Angular 2 files

Leave a Reply

Your email address will not be published. Required fields are marked *