Insights into what moves us. Contributions from the Structr team and guests. The Structr Blog

Axel Morgner
01. December 2014
Structr, REST, Example,

Example Application with Mobile Angular UI

This blog post describes the creation of an example application mentioned in the article about Structr's JSON/REST backend in the german Java Magazin 1/2015, pages 90 ff.

Framework: Mobile Angular UI


To demonstrate how easy it is to create a mobile application with Structr, I was looking for a framework covering three popular demands:

  • optimized for mobile devices
  • based on Bootstrap
  • using AngularJS
There are a couple of others, but eventually I chose Mobile Angular UI.


Prior to the installation of Mobile Angular UI, please remove the Welcome page

Installation in Structr

The easiest way to install a frontend framework like this in Structr is to upload a ZIP file and extract it. In this case, just download the ZIP archive to your local disk, drag and drop the icon onto the Files area and click the Expand icon. Structr automatically creates all folders and files contained in the archive.

Once uploaded and expanded, you need to move the subfolders demo and dist to the root level so that you can access files like e.g. index.html and mobile-angular-ui.min.js through the URLs http://localhost:8082/demo/index.html#/ and http://localhost:8082/dist/js/mobile-angular-ui.min.js.

To make sure all subsequent page requests are directed to this page, change the href attribute of the base tag of the index.html page to

<base href="/demo/index.html" />

You should see the demo page here http://localhost:8082/demo/index.html#/:

Create Data Model

Go to the Schema Editor and create the types Invoice, Customer, Project, Member and Task, and relate them as shown in this picture. Make sure to set the cardinality (1:1, 1:*, *:* etc.) accordingly.

Create and rename the attributes as seen in the following pictures:

Create Test Data

You can now go to the Data section in Structr's backend UI and add objects of the configured custom types.

Data Binding

Now we bind the list of items you see when you click on Scroll to the list of tasks in demo.js:

Change the method header of
 82    app.controller('MainController', function($rootScope, $scope){
 82    app.controller('MainController', function($rootScope, $scope, $http, analytics){
and replace
 92  var scrollItems = [];
 94  for (var i=1; i<=100; i++) {
 95    scrollItems.push('Item ' + i);
 96  }
 98  $scope.scrollItems = scrollItems;
 92  var scrollItems = [];
 94  $http.get('/structr/rest/tasks').
 95  success(function(data, status, headers, config) {
 97    scrollItems = {
 98      return;
 99    });
100    $scope.scrollItems = scrollItems;
101  }).
102  error(function(data, status, headers, config) {
103    console.log(data, status, headers, config);
104  });

Bind Form Action

To make the app able to create invoices, we have to bind the form action to an appropriate HTTP POST request in forms.html and make sure the attribute names given in ng-model match the the ones set in the data model for the Invoice class:

<div content-for="title">

<div class="scrollable">
<div class="scrollable-content section">

<form action="" id="">

<div bs-panel title="Invoice">


label-class="col-xs-3 col-sm-2 col-lg-1"
class="col-xs-9 col-sm-10 col-lg-11"
placeholder="Customer Name"

label-class="col-xs-3 col-sm-2 col-lg-1"
class="col-xs-9 col-sm-10 col-lg-11"

label-class="col-xs-3 col-sm-2 col-lg-1"
class="col-xs-9 col-sm-10 col-lg-11"


label-class="col-xs-3 col-sm-2 col-lg-1"
class="col-xs-9 col-sm-10 col-lg-11"


<div bs-panel title="Notes">
<textarea type="text" ng-model="invoice.mailingAddress" label="Address" bs-form-control> </textarea>

<div bs-panel class="form-actions">
<div content-for="navbarAction" duplicate>
<button class="btn btn-primary" ng-click="createInvoice()">


The final action to is do add the createInvoice method in demo.js to the app controller:

135  $scope.createInvoice = function() {
137    $'/structr/rest/invoices', $scope.invoice).
138    success(function(data, status, headers, config) {
139      console.log(data, status);
140    }).
141    error(function(data, status, headers, config) {
142      console.log(data, status);
143    });
145  };

This just binds the Save button to a HTTP POST action to /structr/rest/invoices, creating a new Invoice object.

You can download the complete demo database (db and files directories) as a ZIP file: