WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

AppML Controllers


The reason for a AppML controller, is to let you control your application.


What Can a Controller Do?

  • Set introductory data
  • Change application data
  • Handle input and output
  • Validate data
  • Summarize data
  • Handle errors
  • Start and stop applications
  • And much more

Without a Controller

By default AppML applications keep running without a controller:

Example

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

With an AppML controller, you can control your application with JavaScript.

The controller is a JavaScript work, provided by you.

The appml-controller ascribe is utilized to allude to a controller function.

Example

<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) {
    on the off chance that ($appml.message == "show") {
        if ($appml.display.name == "CustomerName") {
            $appml.display.value = $appml.display.value.toUpperCase();
        }
    }
}
</script>

The controller (myControlller) in the model above, changes the estimation of "CustomerName" to capitalized, before it is shown.

If you have a controller, AppML will send the application object ($appml) to the controller, for each vital action.

One of the application properties is a message ($appml.message), depicting the application state.

Message Description
ready Sent after AppML is started, and prepared to stack data.
loaded Sent after AppML is completely stacked, prepared to show data.
display Sent before AppML shows an information item.
done Sent after AppML is done (completed displaying).
submit Sent before AppML submits data.
error Sent after AppML has experienced an error.