AppML Data
วัตถุประสงค์หลักของ AppML คือการให้ข้อมูล กับหน้า HTML
กำลังเชื่อมต่อ AppML กับ Data
- AppML สามารถแสดงข้อมูลจากตัวแปร
- AppML สามารถแสดงข้อมูลจากไฟล์ได้
- AppML สามารถแสดงข้อมูลจากฐานข้อมูล
AppML โดยใช้ JavaScript Object
วิธีทั่วไปในการแยก HTML และข้อมูล คือการจัดเก็บข้อมูลในวัตถุ JavaScript
ตัวอย่าง
<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 โดยใช้ไฟล์ JSON
อีกวิธีทั่วไปในการแยก HTML และข้อมูล คือการจัดเก็บข้อมูลในไฟล์ JSON:
ลูกค้า.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"}
]
}
ด้วย AppML คุณสามารถระบุไฟล์ JSON เป็นแหล่งข้อมูลในแอตทริบิวต์ appml-data:
ตัวอย่าง
<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 การใช้ฐานข้อมูล
ด้วยความช่วยเหลือเล็กน้อยจากเว็บเซิร์ฟเวอร์ คุณสามารถป้อนแอปพลิเคชันของคุณด้วยข้อมูล SQL
ตัวอย่างนี้ใช้ PHP เพื่ออ่านข้อมูลจากฐานข้อมูล MySQL:
ตัวอย่าง
<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>
พลังของ AppML
คุณกำลังจะค้นพบพลังของ AppML
AppML สามารถให้ข้อมูล ผู้ควบคุม และแบบจำลองสำหรับ:
- การพัฒนาแอปพลิเคชัน HTML ที่ง่ายสุดๆ
- การสร้างแบบจำลอง การสร้างต้นแบบ และการทดสอบที่ง่ายมาก
คุณสามารถใส่แอปพลิเคชัน AppML ได้มากเท่าที่ต้องการในหน้า HTML
AppML ไม่รบกวนส่วนอื่นของหน้า
คุณมีอิสระ HTML, CSS และ JavaScript เต็มรูปแบบ
AppML สามารถใช้ในการพัฒนาเว็บแอปพลิเคชัน CRUD เต็มรูปแบบ
CRUD: C reate, R ead, U pdate, D elete
หากต้องการค้นพบพลังของ AppML: ดูAppML Demo