I am a beginner in angular4
Currently, I am working on a Registration process that involves multiple steps. To control the visibility of these steps based on certain conditions, I am using the hide/show
functionality. The Registration process consists of both parent and child components, with the child component (a "sidebar" showing values filled in by the user in the last step).
In this process, I am passing an array from the parent to the child component. At each step, I update this array with new values. While I can successfully display the array in the child component's HTML, I encounter issues when trying to log the array in the child component's .ts file.
One specific challenge I'm facing is calculating the user's actual age using their date of birth stored in the array and displaying it on the sidebar.
This is my array: MyArray This is how I pass my array:
Parent.html
<app child [MyArray]="MyArray"></app child>
ChildComponent.ts
import { Component, OnInit, Output, Input } from '@angular/core';
export class SidebarComponent implements OnInit {
@Input() MyArray: string;
ngOnInit() {
console.log(this.MyArray,'ssss');
}
}
If I access MyArray.email in my child.html, the value displays correctly.
Does anyone have any insights into what might be going wrong here?