Parent Component
Child Component
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-parent',
template: `<p>
parent works!
</p>
<app-chiled [messageParentToChiled]="messageParentToChiled"></app-chiled>`,
styleUrls: ['./parent.component.css']
})
export class ParentComponent implements OnInit {
messageParentToChiled = "Parent to parent";
constructor() { }
ngOnInit() {
}
}
import { Component, OnInit, Input,Output,EventEmitter } from '@angular/core';
@Component({
selector: 'app-chiled',
templateUrl: `<p>
chiled works!Message{{messageParentToChiled}}
</p>`,
styleUrls: ['./chiled.component.css']
})
export class ChiledComponent implements OnInit {
@Input() messageParentToChiled:string;
constructor() { }
ngOnInit() {
}
}
No comments:
Post a Comment