I have a Sidebar inside a component like below:
<div class="container-fluid">
<div class="row">
<div class="col-8">
<!--Main Content-->
</div>
<div class="col-4">
<app-sidebar [qdyk]="dyk"></app-sidebar>
</div>
</div>
</div>
In the parent component I set the dyk property:
ngOnInit() {
// Load the current question
this.currentQuestion();
}
// Load the current question
currentQuestion() {
// Get the current question from the API
this.questionService.getCurrentQuestion().subscribe(res => {
// Load the question to angular
this.loadQuestion(res);
});
}
loadQuestion(sequence: any) {
// Load the whole sequence object...
this.sequence = sequence;
this.question = this.sequence.currentQuestion;
this.dyk = this.question.didYouKnow;
console.log(this.dyk);
}
The above console log returns the text I was expecting from the API, but when I try to pass this down to the child I get an undefined
@Input() qdyk: string;
ngOnInit() {
// Show DYK Value from Parent
console.log(this.qdyk);
}
Passing a string value and bypassing the question loading works and outputs the string to the console passed from parent to child (for example: <app-sidebar [qdyk]="'Some Text'"></app-sidebar>) - it's just when I pass in the dynamic value?