API AppML
L'API AppML définit les méthodes et les propriétés d'AppML
Que peuvent faire les méthodes et les propriétés ?
Avec les méthodes et les propriétés, vous pouvez :
- Créer des applications AppML
- Alimenter les applications en données
- Récupérer les données d'application à utiliser dans votre page Web
Exemple
new AppML() crée un nouvel objet AppML.
dataSource définit la source de données de l'objet AppML.
getData() récupère les données.
data.records contient les enregistrements de données.
Vous pouvez boucler les enregistrements et afficher le contenu dans un élément HTML :
Exemple
// Create an AppML object and fetch the data
myObj = new AppML();
myObj.dataSource = "https://www.w3schools.com/appml/customers.php";
myObj.getData();
// Locate the data records
myArr = myObj.data.records;
len = myArr.length;
// Display the records
for (i = 0; i < len; i++) {
txt += myArr[i].CustomerName + "<br>";
}
document.getElementById("demo").innerHTML = txt;
Résultat
Alfreds Futterkiste
Berglunds snabbköp
Centro comercial Moctezuma
Ernst Handel
FISSA Fabrica Inter. Salchichas S.A.
Galería del
gastrónomo
Island Trading
Königlich Essen
Laughing Bacchus Wine
Cellars
Magazzini Alimentari Riuniti
North/South
Paris spécialités
Rattlesnake Canyon Grocery
Simons bistro
The Big Cheese
Vaffeljernet
Wolski Zajazd
Quelques méthodes AppML
Method | Description |
---|---|
new AppML() | Creates a new AppML object |
run() | Runs an application object |
appml("name") | Returns the appml object with the specified name |
displayMessage(text) | Displays a specified message. |
setError(no, description) | Sets a specified error and error description. |
Certaines propriétés AppML
Property | Description |
---|---|
appName | The application name (the container id) |
container | The application container element |
controller | The application controller |
data | The application data object |
dataSource | The application data source |
message | The application message |
Certaines propriétés d'objet de données
Property | Description |
---|---|
data.model | The application data model |
data.records | The application data records |