79463682

Date: 2025-02-24 13:32:42
Score: 0.5
Natty:
Report link

Use alpinejs-xcomponent

https://github.com/lmanukyan/alpinejs-xcomponent

<script src="https://unpkg.com/[email protected]/alpine-components.min.js"></script>
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>

<div x-data="{
    countries: [
        {name: 'Russia', area: 17098246, population: 146150789},
        {name: 'Canada', area: 9984670, population: 41465298},
        {name: 'China', area: 9596960, population: 1408280000},
        {name: 'United States', area: 9525067, population:  340110988},
        {name: 'Brazil', area: 8510346, population:  212583750}
    ]
}">
    <table border="1">
        <tr>
            <th>Name</th>
            <th>Area</th>
            <th>Population</th>
        </tr>
        <template x-for="country in countries">
            <tr x-data="template('country-item')" x-bind="bind" x-model="country"></tr>
        </template>
    </table>
</div>

<template id="country-item">
    <td x-text="props.name"></td>
    <td x-text="props.area"></td>
    <td x-text="props.population"></td>
</template>

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Levon Manukyan