0

Hi I am trying to learn new things in LWC ,, kindly help me out for this. Scenario : I ahve a JSON .js file which is i have imported in the JS file and trying to use it in the HTML for my for:each iteration,,, for:each iterator should iterate over the Complete JSON file and print the same number of lightning icon. below is my code:

JSON.js file
const OCStat = (() => {
    return {
        COCStat: [
               {
                "CDATE":"07/07/2020",
                "LDATE":"07/09/2020",
                "Acciuy #":"jngg",
                "Myweyru":"hggfhfb"
              },
            {
                "CDATE":"07/07/2020",
                "LDATE":"07/09/2020",
                "Acciuy #":"jngg",
                "Myweyru":"hggfhfb"
            },
            {
                "CDATE":"07/07/2020",
                "LDATE":"07/09/2020",
                "Acciuy #":"jngg",
                "Myweyru":"hggfhfb"
            }
        ]
    }
});

export default OCStat;

JS file:

import { LightningElement, track, api } from 'lwc';
import cOJSON from './OCStatJSON.js';

export default class COSTat extends LightningElement {

    @track cOHTs = cOJSON();
    @track cOHTs1 = JSON.parse(JSON.stringify(this.cOHTs));
    
} 

HTML file:

<template for:each={cOHTs1} for:item='cdateObj'>
                    <tr  key={cdateObj.CDATE}>
                        <td>
                            <div >
                                <lightning-button-icon '>
                                </lightning-button-icon>
                            </div>
                        </td>
                    </tr>
  </template>

error i am getting:

Error :  [t[xe] is not a function]

Kindly help me out for this ...Thanks'

0

You forgot about the top-level element in your JSON:

<template for:each={cOHTs1.COCStat} for:item="cdateObj">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.