Understanding @input – from parent to child

I try to learn Angular and now I’m at the @Input stage.

I have a main app and a child component. In app.component I have a test variable. I want to pass this variable from app.component.ts to child.component.ts.

app.component.ts:
export class AppComponent {
test = 10;
}  

child.component.ts:
export class AppComponent {
@Input() fromParent: number;
  childVar = fromParent + 5;
} 
show(){
console.log(this.childVar);
} //this should to show 15 in console...

Now, how can I do this?
Thank you very much !!!

Source: Angular

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.