Child to parent should occur via event emitter Sent from BlueMail
On Jul 3, 2020, 8:12 PM, at 8:12 PM, 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. -- 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/5a8377e4-ab4e-4d5a-8769-f6770ea3d36c%40gmail.com.