Reputation: 5674
import {Component, OnInit, ChangeDetectionStrategy, ElementRef, Input} from '@angular/core';
import {FadeInTop} from "../../../../../shared/animations/fade-in-top.decorator";
declare var $: any;
@FadeInTop()
@Component({
selector: 'order-progressbar-dynamic',
templateUrl: 'order-progressbar-dynamic.component.html',
})
export class OrderProgressBarDynamicComponent {
@Input() public data: any;
public progressBar: {index: number, btnID: string, btnTag: string, title: string, status: boolean, statusTag: string, prevStepStatus: boolean}[];
constructor(private el: ElementRef) {
this.generateDataForProgressbar();
}
public generateDataForProgressbar() {
if (this.data) {
this.progressBar = [
{
"index": 0,
"btnID": "orderConfirmed",
"status": this.data.orderStatus.saleConfirmed,
},
{
"index": 1,
"btnID": "item",
"status": this.data.orderStatus.item,
}
]
}
}
}
if(this.data) is fail all the time, data is undefined, but when using it from order-progressbar-dynamic.component.html
i do get the values. how can i make the @Input values to be available from the class methods?
Upvotes: 0
Views: 560
Reputation: 214007
Use ngOnInit
hook to get @Input
value
constructor(private el: ElementRef) {}
ngOnInit() {
this.generateDataForProgressbar();
}
Upvotes: 3