AppML Come fare per


Come creare un'applicazione AppML in 2 semplici passaggi .


1. Crea una pagina utilizzando HTML e CSS

HTML

<!DOCTYPE html>
<html lang="en-US">
<link rel="stylesheet" href="style.css">
<title>Customers</title>
<body>

<h1>Customers</h1>

<table>
<tr>
  <th>Customer</th>
  <th>City</th>
  <th>Country</th>
</tr>
<tr>
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

</body>
</html>

Le parentesi {{ }} sono segnaposto per i dati AppML.

CSS

body {
  font: 14px Verdana, sans-serif;
}

h1 {
  color: #996600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border: 1px solid grey;
  padding: 5px;
  text-align: left;
}

table tr:nth-child(odd) {
  background-color: #f1f1f1;
}

Sentiti libero di sostituire il CSS con il tuo foglio di stile preferito.


2. Aggiungi AppML

Usa AppML per aggiungere dati alla tua pagina:

Esempio

<!DOCTYPE html>
<html lang="en-US">
<title>Customers</title>
<link rel="stylesheet" href="style.css">
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"></script>
<body>

<h1>Customers</h1>

<table appml-data="customers.js">
<tr>
  <th>Customer</th>
  <th>City</th>
  <th>Country</th>
</tr>
<tr appml-repeat="records">
  <td>{{CustomerName}}</td>
  <td>{{City}}</td>
  <td>{{Country}}</td>
</tr>
</table>

</body>
</html>

Spiegazione di AppML:

<script src="https://www.w3schools.com/appml/2.0.3/appml.js"> aggiunge AppML alla tua pagina.

appml-data = "customers.js" connette i dati AppML (customers.js) a un elemento HTML (<table>).

In questo caso abbiamo utilizzato un file JSON:

appml-repeat="records" ripete un elemento HTML (<tr>) per ogni elemento (record) in un oggetto dati.

Le parentesi {{ }} sono segnaposto per i dati AppML.