export class ChildComponent {
message: string = 'Hello!!!';
}import { Component, ViewChild, AfterViewInit} from '@angular/core';
import { ChildComponent } from '../child/child.component'
export class ShoppingCartComponent implements ControlValueAccessor, AfterViewInit {
messageFromChild : string;
@ViewChild(ChildComponent) myChild;
ngAfterViewInit() {
this.messageFromChild = this.myChild.message;
}
}
<h1> From Child - {{ messageFromChild }} </h1>|
|
Maninder Kumar
about.me/maninder.s.kumar
|
--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/ffc8ca20-d4b0-4894-bc4c-f8316c90e69eo%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/CABOHK3RCb2ZR_PgRNnbOB7hTg%3DEtLCzYjbvc%3DByHCGsO_71Ytg%40mail.gmail.com.
Hi.This is quite uncommon for a child component to pass a static string to its parent. My guess is that the message is going to be edited or changed overtime.. in which case the child should emit the new value when it changed (via the @Output decorator and an eventEmitter)If that's not the case would you mind explaining what is really needed here, please?
To unsubscribe from this group and stop receiving emails from it, send an email to ang...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/angular/ffc8ca20-d4b0-4894-bc4c-f8316c90e69eo%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ang...@googlegroups.com.