AppML- instructies


Een AppML-applicatie bouwen in 2 eenvoudige stappen .


1. Maak een pagina met HTML en 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>

De {{ }} haakjes zijn tijdelijke aanduidingen voor AppML-gegevens.

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;
}

Voel je vrij om de CSS te vervangen door je eigen favoriete stylesheet.


2. AppML toevoegen

Gebruik AppML om gegevens aan uw pagina toe te voegen:

Voorbeeld

<!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>

AppML uitgelegd:

<script src="https://www.w3schools.com/appml/2.0.3/appml.js"> voegt AppML toe aan je pagina.

appml-data = "customers.js" verbindt AppML-gegevens (customers.js) met een HTML-element (<tabel>).

In dit geval hebben we een JSON-bestand gebruikt:

appml-repeat="records" herhaalt een HTML-element (<tr>) voor elk item (records) in een gegevensobject.

De {{ }} haakjes zijn tijdelijke aanduidingen voor AppML-gegevens.