import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-parent',
templateUrl: './parent.component.html',
styleUrls: ['./parent.component.css']
})
export class ParentComponent implements OnInit {
variableParent:string='je viens du parent'
constructor() { }
ngOnInit(): void {
}
}
<p>parent works!</p>
<app-enfant [ValueChild]="variableParent" ></app-enfant>
//**********child component*****
import {Component, Input, OnInit} from '@angular/core';
@Component({
selector: 'app-enfant',
templateUrl: './enfant.component.html',
styleUrls: ['./enfant.component.css']
})
export class EnfantComponent implements OnInit {
@Input () ValueChild:any
constructor() { }
ngOnInit(): void {
console.log(this.ValueChild)
}
}
<p>enfant works!</p>
<h3>
{{ValueChild}}
</h3>
//Unfortunately {{ValueChild}} is undefined I don't know why normally ValueChild //should display: "je viens du parent" in the browser please could you help me to solve this issue?