I have many Arrays in a component and i need to pass this information for the sun's component. I think do that from @Input method. In the parent component i give many pushs in thats arrays. After finishing the pushes I would need the @Input to be given to the child component. But the way I'm trying, it's getting the initial value of Arrays, like 0 or empty. Can someone help me?
Parent Component HTML:
<div class="past-information">
<app-lunch-review-dialog [namePackage]="packageName" [estaticValue]="valueEstatic"
[valueBag]="packageValue" [linkImage]="packageImage" [amountBag]="packageAmount"
[finalValueBag]="sum"></app-lunch-review-dialog>
</div>
Sun Component TS:
@Input() namePackage: Array<string> = []
@Input() estaticValue: Array<string> = []
@Input() valueBag: Array<string> = []
@Input() linkImage: Array<string> = []
@Input() amountBag: Array<string> = []
@Input() finalValueBag: number;
Parent code fills the array:
let bagValue = this.packageSelected.value.toString()
let bagName = this.packageSelected.name
let bagAmount = this.packageSelected.bagAmount.toString()
let bagImage = this.packageSelected.imagePath
this.packageName.push(bagName);
this.valueEstatic.push(bagValue)
this.packageValue.push(bagValue);
this.packageImage.push(bagImage);
this.packageAmount.push(bagAmount);
How i call the @Input in the Child Component:
ngOnInit(){
console.log("@Input NP is " + this.namePackage);
console.log("@Input EV is " + this.estaticValue);
console.log("@Input VB is " + this.valueBag);
console.log("@Input LI is " + this.linkImage);
console.log("@Input AB is " + this.amountBag);
console.log("@Input FVB is " + this.finalValueBag);
}
When i call that console.log returns this way: console.log