Within this context, I am endeavoring to transmit the values of the bookingInfo array (assigned as
this.bookingInfo = bookings.responseObj.txnValues;
) to my child component. The current setting pertains to my parent component.
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.scss']
})
export class DashboardComponent implements OnInit{
lineChart = ['line_chart1', 'line_chart2', 'line_chart3', 'line_chart4', 'line_chart5'];
value = ['33.5M', '67.9M', '90.9M', '09.9M'];
names = ['cancellations', 'Bookings', 'Modifications', 'Revenue' ];
bookingInfo = [];
ngOnInit() {
this.getBookingInfo();
}
getBookingInfo() {
const params = [];
params.push({code: 'dateType', name: 'BOOKING'});
params.push({code: 'fromDate', name: '2019-01-01'});
params.push({code: 'toDate', name: '2019-12-31'});
this.ServiceHandler.getTxnInfo([], params).subscribe(
bookings => {
this.bookingInfo = bookings.responseObj.txnValues;
console.log(this.bookingInfo);
});
}
}
The file for my dashboard component is named dashboard.component.html.
<app-summary-chips [lineChart]="lineChart[0]" [value] = "value[0]" [name] = "names[0]" [data] = "bookingInfo"></app-summary-chips>
This serves as the child component.
@Component({
selector: 'app-summary-chips',
templateUrl: './summary-chips.component.html',
styleUrls: ['./summary-chips.component.scss']
})
export class SummaryChipsComponent implements OnInit {
@Input('lineChart') lineChart: string;
@Input('value') value: string;
@Input('name') name: string;
@Input() data: [];
ngOnInit() {
console.log('line chart: ', this.lineChart);
console.log(this.data);
}
}
This corresponds with the content in summary-chips.component.html
<div class="l-content-wrapper c-summary-chip oh" >
<div class="c-summary-chip__value">{{value}}</div>
<div class="c-summary-chip__txt">{{name}}</div>
<div id= "{{lineChart}}" class="c-summary-chip__graph ">
</div>
</div>
However, upon executing console.log(this.data);
within the child component, it displays an empty array.