Hi i have a problem with that. In my component i have a inputt setter like this :
@Input() set editStatus(status: boolean) {
this.savedEditStatus = status;
if (this.savedEditStatus === true && this.getTrigg === true) {
this.getDataFromFlex("SHOWS_L").then((data: any) => {
this.getTrigg = false;
this.lengthDataOptions = data;
})
} else {
this.getTrigg = true;
this.lengthDataOptions = undefined;
}
};
My problem is i get two edit status with value true and they are comming in the almost same time. So right now for this component in this case the getDataFromFlex function will be called two times. I don't want the second time call so i think the getTrigg(boolean) will be a solve. And its doesn't work. So i need a bit of help from you guys. The getTrigg is default on component initiation set for true
I recomend you to use the ngOnChanges interface to do this kind of communication with external components. This will ensure that you have the expected value to do what you need after this value changes:
import { Component, OnInit, Input, OnChanges, SimpleChange } from '@angular/core';
@Input() savedEditStatus: boolean; // change to field not getter / setter
ngOnChanges(changes: { [propKey: string]: SimpleChange }) {
if (changes['savedEditStatus'] && changes['savedEditStatus'].currentValue === true &&
this.getTrigg === true) {
this.getDataFromFlex("SHOWS_L").then((data: any) => {
this.getTrigg = false;
this.lengthDataOptions = data;
})
} else {
this.getTrigg = true;
this.lengthDataOptions = undefined;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With