I am having problem in dynamically getting the value in my child Lightning Web Component I have a Parent Component and Child Component. I am passing the @api value as follows :
Parent.html
<lightning-input type="checkbox" label="isFieldChecked" value={isfieldchecked} onchange={handleValueChange}>
<c-child
isvaluechecked={isfieldchecked}
></c-child>
</lightning-input>
Parent.js
isfieldchecked = false;
handleValueChange(event) {
this.isfieldchecked = event.target.checked; //value onchange is not getting reflected in child component
}
child.html
<lightning-input type="checkbox" label="isChecked" value={isfieldchecked} onchange={handlecheckboxchanged}></lightning-input>
child.js
@api isvaluechecked;
connectedCallback() {
console.log('isValueChanged::' + this.isvaluechecked);
}
handlecheckboxchanged() {
if(this.isvaluechecked) {
console.log('isValueChanged::' + this.isvaluechecked); //cannot see the value updated when updated on parent
//perform some operations
}
}
In the above scenario, when I check/uncheck the checkbox in the parent component, I dont see it changed in the child component where I am invoking the onchange method.