Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Remember the ng-click attribute in the "button" div in our HTML snippet? Well, here we set the function reference on our scope, to bind to that element's click handler:

Code Block
languagejs
// custom click handler
$scope.getData = getData;

...

To populate our view the first time it is loaded, we need to send an initial event to the server explicitly:

Code Block
languagejs
// get data the first time...
getData();

...

Code Block
languagejs
// cleanup
$scope.$on('$destroy', function () {
    wss.unbindHandlers(handlers);
    ks.unbindKeys();
    $log.log('OvSampleCustomCtrl has been destroyed');
});

We unbind our event handlers and key bindings, and log a message to the console.

 

The last thing the controller does when it is initialized is to log to the console:

Code Block
languagejs
 $log.log('OvSampleCustomCtrl has been created');

sampleCustom.css

Glue Files

css.html

...

The last file in our client-side trio is the stylesheet for the custom view:

Code Block
languagecss
linenumberstrue
collapsetrue
/* css for sample app view */

#ov-sample-custom {
    padding: 20px;
}
.light #ov-sample-custom {
    color: navy;
}
.dark #ov-sample-custom {
    color: #88f;
}

#ov-sample-custom .button-panel {
    margin: 10px;
    width: 200px;
}

.light #ov-sample-custom .button-panel {
    background-color: #ccf;
}
.dark #ov-sample-custom .button-panel {
    background-color: #444;
}

#ov-sample-custom .my-button {
    cursor: pointer;
    padding: 4px;
    text-align: center;
}

.light #ov-sample-custom .my-button {
    color: white;
    background-color: #99d;
}
.dark #ov-sample-custom .my-button {
    color: black;
    background-color: #aaa;
}

#ov-sample-custom .number {
    font-size: 140%;
    text-align: right;
}

#ov-sample-custom .quote {
    margin: 10px 20px;
    font-style: italic;
} 

It should be fairly self-explanatory. However, note the use of the .light and .dark classes to change color selections based on each of the GUI's themes.

Glue Files

The final piece to the puzzle are the two "glue" files used to patch references to our client-side source into index.html. These files are located in the ~src/main/resources directory.

css.html

This is a short snippet that is injected into index.html. It contains exactly one line:

Code Block
languagexml
<link rel="stylesheet" href="app/view/sampleCustom/sampleCustom.css"> 

js.html

This is a short snippet that is injected into index.html. It contains exactly one line:

Code Block
languagexml
 <script src="app/view/sampleCustom/sampleCustom.js"></script>