function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Princes91221Princes91221 

Cannot iterate an Array

Hello all,

Hope you guys are safe and doing well.

I'm new to Salesforce Development and trying to iterate an array but enable to do it.

I want to display 7 input fields.

While opening the org I'm getting the following error
"Error during LWC component connect phase: [Cannot read properties of undefined (reading 'inputHours')]"

Here's my HTML Code
<div class="slds-form-element slds-var-p-around_small">
    <div class="slds-grid">
        <template if:true={projectHoursDatas}>
            <template for:each={projectHoursDatas} for:item="projectHoursData">
                <div class="slds-col slds-size_2-of-12" key={projectHoursData.id}>
                    <b>{ projectHoursData.projectName }</b>
                </div>
                <template for:each={projectsHoursData.inputHours} for:item="inputHourValue">
                    <div class="slds-col slds-size_1-of-12 slds-text-align_center" key={inputHourValue}>
                        <!-- <input type="text" class="slds-input" key={inputHourValue} /> -->
                        <span>{inputHours}</span>
                    </div>
                </template>
                <div class="slds-col slds-size_1-of-12 slds-text-align_center" key={projectHoursData}>
                    <p>00.00</p>
                </div>
            </template>
        </template>
    </div>
</div>

and here's my JS Controller
import { LightningElement } from 'lwc';

export default class Time extends LightningElement {
    headers = [
        {
            day: 'Mo',
            date: '08 - 11'
        },
        {
            day: 'Tu',
            date: '09 - 11'
        },
        {
            day: 'We',
            date: '10 - 11'
        },
        {
            day: 'Th',
            date: '11 - 11'
        },
        {
            day: 'Fr',
            date: '12 - 11'
        },
        {
            day: 'Sa',
            date: '13 - 11'
        },
        {
            day: 'Su',
            date: '14 - 11'
        }
    ];

    projectHoursDatas = [
        {
            Id: 1,
            projectName: 'Manage Time',
            inputHours: [0, 0, 0, 0, 0, 0, 0]
        }
    ];

    enteredValues= [
        {
            Id: 1,
            hours: '00.00'
        },
        {
            Id: 2,
            hours: '00.00'
        },
        {
            Id: 3,
            hours: '00.00'
        },
        {
            Id: 4,
            hours: '00.00'
        },
        {
            Id: 5,
            hours: '00.00'
        },
        {
            Id: 6,
            hours: '00.00'
        },
        {
            Id: 7,
            hours: '00.00'
        }
    ];
}