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? Le sam. 4 juil. 2020 à 12:20, maninder singh Kumar < maninder.s.ku...@gmail.com> a écrit : > Have tried loading the result into console.log ? Normally gives a better > understanding. > > <https://about.me/maninder.s.kumar?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=edit_panel&utm_content=thumb> > Maninder Kumar > about.me/maninder.s.kumar > <https://about.me/maninder.s.kumar?promo=email_sig&utm_source=product&utm_medium=email_sig&utm_campaign=edit_panel&utm_content=thumb> > > > On Sat, Jul 4, 2020 at 5:43 AM Maureen Moore <makam...@gmail.com> wrote: > >> The tutorial that I followed said to add the parent component to the >> bootstrap array in app.module.ts but when I did that I got a blank page. >> >> On Friday, July 3, 2020 at 7:58:58 PM UTC-4, Maureen Moore wrote: >>> >>> So I am trying to get a value from my child component to print in my >>> parent component and I tried the following: >>> >>> In my child component ts: >>> >>> >>> export class ChildComponent { >>> message: string = 'Hello!!!'; >>> } >>> >>> In my parent component ts: >>> 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; >>> } >>> } >>> >>> >>> >>> In my parent component html: >>> >>> <h1> From Child - {{ messageFromChild }} </h1> >>> >>> I don't get any errors but {{ messageFromChild }} is blank. >>> >> -- >> 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+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/angular/ffc8ca20-d4b0-4894-bc4c-f8316c90e69eo%40googlegroups.com >> <https://groups.google.com/d/msgid/angular/ffc8ca20-d4b0-4894-bc4c-f8316c90e69eo%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/angular/CABOHK3RCb2ZR_PgRNnbOB7hTg%3DEtLCzYjbvc%3DByHCGsO_71Ytg%40mail.gmail.com > <https://groups.google.com/d/msgid/angular/CABOHK3RCb2ZR_PgRNnbOB7hTg%3DEtLCzYjbvc%3DByHCGsO_71Ytg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/CAJ7E9zHHBC%3DSYH5dAcTYJr%2BcK-R9UrzbJ4JfQsL8Cy5MbNjWTg%40mail.gmail.com.