最新的Web开发教程
 

AppML数据


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演示