Data AppML
Tujuan utama AppML adalah menyediakan data ke halaman HTML.
Menghubungkan AppML ke Data
- AppML dapat menampilkan data dari variabel
- AppML dapat menampilkan data dari file
- AppML dapat menampilkan data dari database
AppML Menggunakan Objek JavaScript
Cara umum untuk memisahkan HTML dan Data, adalah dengan menyimpan data dalam objek JavaScript.
Contoh
<table appml-data="dataObj">
<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>
<script>
var dataObj = {
"records":[
{"CustomerName":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's
Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds
snabbköp","City":"Luleå","Country":"Sweden"},
{"CustomerName":"Blauer See
Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel
père et fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Bólido
Comidas preparadas","City":"Madrid","Country":"Spain"},
{"CustomerName":"Bon
app'","City":"Marseille","Country":"France"},
{"CustomerName":"Bottom-Dollar
Marketse","City":"Tsawassen","Country":"Canada"},
{"CustomerName":"Cactus
Comidas para llevar","City":"Buenos Aires","Country":"Argentina"},
{"CustomerName":"Centro
comercial Moctezuma","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comércio Mineiro","City":"São Paulo","Country":"Brazil"}
]};
</script>
AppML Menggunakan File JSON
Cara umum lainnya untuk memisahkan HTML dan Data, adalah dengan menyimpan data dalam file JSON:
pelanggan.js
{
"records":[
{"CustomerName":"Alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"Ana Trujillo Emparedados y helados","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Antonio Moreno Taquería","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds
snabbköp","City":"Luleå","Country":"Sweden"},
{"CustomerName":"Blauer See
Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel
père et fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Bólido
Comidas preparadas","City":"Madrid","Country":"Spain"},
{"CustomerName":"Bon
app'","City":"Marseille","Country":"France"},
{"CustomerName":"Bottom-Dollar
Marketse","City":"Tsawassen","Country":"Canada"},
{"CustomerName":"Cactus
Comidas para llevar","City":"Buenos Aires","Country":"Argentina"},
{"CustomerName":"Centro
comercial Moctezuma","City":"México D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comércio Mineiro","City":"São Paulo","Country":"Brazil"}
]
}
Dengan AppML, Anda dapat menentukan file JSON sebagai sumber data di atribut appml-data:
Contoh
<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>
AppML Menggunakan Database
Dengan sedikit bantuan dari server web, Anda dapat memberi makan aplikasi Anda dengan data SQL.
Contoh ini menggunakan PHP untuk membaca data dari database MySQL:
Contoh
<table appml-data="https://www.w3schools.com/appml/customers.php">
<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>
Kekuatan AppML
Anda akan menemukan kekuatan AppML.
AppML dapat memberi Anda data, pengontrol, dan model untuk:
- Pengembangan Aplikasi HTML yang sangat mudah
- Pemodelan, Pembuatan Prototipe, dan Pengujian Super-mudah
Anda dapat menempatkan aplikasi AppML sebanyak yang Anda suka di dalam halaman HTML.
AppML tidak mengganggu bagian lain dari halaman.
Anda memiliki kebebasan penuh HTML, CSS, dan JavaScript.
AppML dapat digunakan untuk mengembangkan aplikasi web CRUD skala penuh.
CRUD: Buat , Baca , Perbarui , Hapus .
Untuk mengetahui kekuatan AppML: Lihat Demo AppML .