...
The outer <div> element defines the contents of our custom "view". It should use a dash-delimited "id" of the internal identifier for the view, prefixed with "ov". So, in our example, "sampleCustom" becomes "ov-sample-custom". ("ov" stands for "ONOS view").
...
Note that we have used Angular's ng-click attribute in the button <div> to instruct Angular to invoke the getData() function (defined on our "scope" (, see later), whenever the user clicks on the <div>.
Data Panel
We have defined a <div> to create a "data panel" below the button panel:
Code Block | ||
---|---|---|
| ||
<div class="data-panel"> <table> <tr> <td> Number </td> <td class="number"> {{data.number}} </td> </tr> <tr> <td> Square </td> <td class="number"> {{data.square}} </td> </tr> <tr> <td> Cube </td> <td class="number"> {{data.cube}} </td> </tr> </table> <p> A message from our sponsors: </p> <p> <span class="quote"> {{data.message}} </span> </p> </div> |
...
Code Block | ||
---|---|---|
| ||
// js for sample app custom view (function () { 'use strict'; ... }()); |
Variables
Variables are declared to hold injected references (console logger, scope, services...), and configuration "constants":
Code Block | ||
---|---|---|
| ||
// injected refs var $log, $scope, wss, ks; // constants var dataReq = 'sampleCustomDataRequest', dataResp = 'sampleCustomDataResponse'; |
The dataReq
Defining the Controller
We'll skip over the helper functions for the moment and focus on the controller:
...