Hello,
how to pass clicked checkbox value from root to child component.
I have sidebar menu in app component and i need to pass value of selected checbox to child component.
Thanks in advance!!!
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Bhairab DuttPosted Aug 24, 2018, 2:18 PM
Thanks
Jitendra KumarPosted Aug 23, 2018, 7:48 AM
Component B Html
Component B.ts
Amit Kumar SinghPosted Aug 23, 2018, 7:39 AM
Jitendra KumarPosted Aug 23, 2018, 7:32 AM
import { Component } from '@angular/core';@Component({selector: 'appchild',template: `Hi {greetMessage}
`})export class AppChildComponent {greetMessage: string = "I am Child";import {Component } from '@angular/core';import {AppChildComponent} from './appchild.component';@Component({selector: 'my-app',template: `
Hello {message}
})export class AppComponent {message : string = "I am Parent";}Passing Data From Parent Component to Child Component
import { Component,Input,OnInit } from '@angular/core';@Component({selector: 'appchild',template: `Hi {{greetMessage}}
`})export class AppChildComponent implements OnInit{@Input() greetMessage: string ;constructor(){}import {Component } from '@angular/core';import {AppChildComponent} from './appchild.component';@Component({selector: 'my-app',template: `
Hello {{message}}
`,})export class AppComponent {message : string = "I am Parent";childmessage : string = "I am passed from Parent to child component"}ngOnInit(){}}