I'm diving into Angular and currently working on the @Input
phase.
Within my main app, there's a child component. Inside app.component.ts
, I've declared a test variable that I wish to pass from app.component.ts
to child.component.ts
.
// app.component.ts:
export class AppComponent {
test = 10;
}
// child.component.ts:
export class ChildComponent {
@Input() fromParent: number;
childVar = fromParent + 5;
show() {
console.log(this.childVar);
} //this should to show 15 in console...
}
So, how exactly can I achieve this? Any suggestions?