I am trying to pass value from parent LWC component to child LWC component api property, but i am getting TypeError: Cannot read properties of undefined (reading 'Id') ?
Parent.html
<c-child total-list ={totalList}>
Parent.js
import { LightningElement, track,api } from "lwc";
export default class Parent extends LightningElement {
totalList =[];
data=[
{
ProductType: "Phone"
ProductList: (2) [{id:'12',Name:"Product1"}, {…}]
}
this.totalList= this.data.filter(e=>e.recId ===targetId).map(e=>e.ProductList);
}
Child.js
import { LightningElement, track } from "lwc";
export default class Child extends LightningElement {
@api totalList;
}
Child.html
<template for:each={totalList} for:item="prdt">
<div key={prdt.Id}>
{prdt.Name}
</div>
</template>
api
. Is this a mistake in your code snippet or in your component?