appML的主要目的是提供數據的HTML頁面。
連接appML到數據
- appML可以顯示來自變量的數據
- appML可以顯示從文件中的數據
- appML可以顯示從數據庫中的數據
appML使用JavaScript對象
分離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":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"antonio Moreno Taqueria","City":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's
Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds
snabbkop","City":"Lulea","Country":"Sweden"},
{"CustomerName":"Blauer See
Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel
pere et fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Bolido
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":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comercio Mineiro","City":"Sao Paulo","Country":"Brazil"}
]};
</script>
試一試» appML使用JSON文件
分離HTML和數據另一種常見的方法是將數據存儲在一個JSON文件:
customers.js
{
"records":[
{"CustomerName":"alfreds Futterkiste","City":"Berlin","Country":"Germany"},
{"CustomerName":"ana Trujillo Emparedados y helados","City":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"antonio Moreno Taqueria","City":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"around the Horn","City":"London","Country":"UK"},
{"CustomerName":"B's Beverages","City":"London","Country":"UK"},
{"CustomerName":"Berglunds
snabbkop","City":"Lulea","Country":"Sweden"},
{"CustomerName":"Blauer See
Delikatessen","City":"Mannheim","Country":"Germany"},
{"CustomerName":"Blondel
pere et fils","City":"Strasbourg","Country":"France"},
{"CustomerName":"Bolido
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":"Mexico D.F.","Country":"Mexico"},
{"CustomerName":"Chop-suey Chinese","City":"Bern","Country":"Switzerland"},
{"CustomerName":"Comercio Mineiro","City":"Sao 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使用數據庫
從Web服務器的幫助不大,你可以餵與SQL數據應用程序。
本例中使用PHP來從一個MySQL數據庫中讀取數據:
例
<table appml-data=" http://www.w3ii.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>
試一試» 此示例使用.NET從一個SQL Server數據庫中讀取數據:
例
<table appml-data=" http://www.w3ii.com/appml/customers.aspx" >
<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 Web應用程序。
CRUD:C reate,R EAD,U PDATE,D elete。
要發現appML的功率: 查看一個appML演示 。