Dane AppML


Głównym celem AppML jest dostarczanie danych do stron HTML.


Podłączanie AppML do danych

  • AppML może wyświetlać dane ze zmiennych
  • AppML może wyświetlać dane z plików
  • AppML może wyświetlać dane z baz danych

AppML przy użyciu obiektu JavaScript

Typowym sposobem oddzielenia HTML i Data jest przechowywanie danych w obiekcie JavaScript.

Przykład

<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 przy użyciu pliku JSON

Innym powszechnym sposobem oddzielenia kodu HTML i danych jest przechowywanie danych w pliku JSON:

klienci.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"}
]
}

Dzięki AppML możesz określić plik JSON jako źródło danych w atrybucie appml-data:

Przykład

<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 przy użyciu bazy danych

Z niewielką pomocą serwera WWW możesz zasilić swoją aplikację danymi SQL.

Ten przykład używa PHP do odczytu danych z bazy danych MySQL:

Przykład

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

Potęga AppML

Za chwilę odkryjesz potęgę AppML.

AppML może dostarczyć dane, kontrolery i modele dla:

  • Bardzo łatwe tworzenie aplikacji HTML
  • Super łatwe modelowanie, prototypowanie i testowanie

Na stronie HTML możesz umieścić dowolną liczbę aplikacji AppML.

AppML nie koliduje z innymi częściami strony.

Masz pełną swobodę HTML, CSS i JavaScript.

AppML może być używany do tworzenia pełnowymiarowych aplikacji internetowych CRUD.

CRUD: Utwórz , odczytaj , zaktualizuj , usuń .

 Aby odkryć potęgę AppML: Obejrzyj demonstrację AppML .