Данные 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":"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: создать , прочитать , обновить , удалить .

 Чтобы узнать о возможностях AppML: просмотрите демонстрацию AppML .