HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
The purpose of an AppML controller, is to let you control your application
By default AppML applications run without a controller:
<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>
With an AppML controller, you can control your application with JavaScript.
The controller is a JavaScript function, provided by you.
The appml-controller attribute is used to refer to a controller function.
<h1>Customers</h1>
<table appml-data="customers.js" appml-controller="myController">
<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>
function myController($appml) {
if ($appml.message == "display") {
if ($appml.display.name == "CustomerName")
{
$appml.display.value = $appml.display.value.toUpperCase();
}
}
}
</script>
The controller (myController) in the example above, changes the value of "CustomerName" to uppercase, before it is displayed.
If you have a controller, AppML will send the application object ($appml) to the controller, for every important action.
One of the application properties is a message ($appml.message), describing the application state.
Message | Description |
---|---|
ready | Sent after AppML is initiated, and ready to load data. |
loaded | Sent after AppML is fully loaded, ready to display data. |
display | Sent before AppML displays a data item. |
done | Sent after AppML is done (finished displaying). |
submit | Sent before AppML submits data. |
error | Sent after AppML has encountered an error. |
Messages are explained in the next chapter.