Your AngularJS app

Now that we’ve established a database connection, it’s time to work on the web side of your app. To start, we’ll create some files in sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage.


This is your landing page. Its purpose is to pull in all the JavaScript and CSS that your app might need as well as to set up your AngularJS app (app.js) and your app’s controller (controller.js), data-services (data-service.js), and routing information (route.js) — more on these in a moment. There is likely much that can be removed from this file (it is boilerplate copied from a sample Portal SDK app), but to save yourself headaches at first, just cut and paste all of it into the sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/myfirstpage.html you created earlier in, redundancies and all:

<!DOCTYPE html>
<!-- Single-page application for EPSDK-App using DS2 look and feel. -->
    <meta charset="ISO-8859-1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />


    <!-- B2b Library -->
    <link rel="stylesheet" type="text/css" href="app/fusion/external/b2b/css/b2b-angular/b2b-angular.css">
    <link rel="stylesheet" type="text/css" href="app/fusion/external/b2b/css/b2b-angular/font_icons.css">

    <!-- icons in open source -->
    <link rel="stylesheet" type="text/css" href="app/fusion/external/ds2/css/digital-ng-library/ionicons.css">
    <link rel="stylesheet" type="text/css" href="app/fusion/external/ds2/css/digital-ng-library/ecomp-ionicons.css">

    <link rel="stylesheet" type="text/css" href="app/fusion/external/angular-bootstrap/ui-bootstrap-csp.css">
    <link rel="stylesheet" type="text/css" href="app/fusion/external/angular-gridster/dist/angular-gridster.min.css">
    <link rel="stylesheet" type="text/css" href="static/fusion/sample/css/scribble.css" />
    <link rel="stylesheet" type="text/css" href="static/fusion/sample/css/welcome.css" />

    <link rel="stylesheet" type="text/css" href="app/fusion/styles/ecomp.css">

    <!-- Common scripts -->
    <script src="app/fusion/external/angular-1.4.8/angular.min.js"></script>
    <script src="app/fusion/external/angular-1.4.8/angular-messages.js"></script>
    <script src="app/fusion/external/angular-1.4.8/angular-touch.js"></script>
    <script src="app/fusion/external/angular-1.4.8/angular-sanitize.js"></script>
    <script src="app/fusion/external/angular-1.4.8/angular-route.min.js"></script>
    <script src="app/fusion/external/angular-1.4.8/angular-cookies.min.js"></script>
    <script src="app/fusion/external/jquery/dist/jquery.min.js"></script>
    <script src="app/fusion/external/javascript-detect-element-resize/jquery.resize.js"></script>
    <script src="app/fusion/external/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
    <script src="app/fusion/external/angular-gridster/dist/angular-gridster.min.js"></script>

    <!-- EPSDK App scripts and common services -->
    <!-- B2b Library -->
    <script src="app/fusion/external/b2b/js/b2b-angular/b2b-library.min.js"></script>
    <script src="app/fusion/scripts/DS2-services/ds2-modal/modalService.js"></script>
    <script src="app/fusion/scripts/myapp/myfirstpage/app.js"></script>

    <script src="app/fusion/scripts/DS2-services/userInfoServiceDS2.js"></script>
    <script src="app/fusion/scripts/DS2-services/headerServiceDS2.js"></script>
    <script src="app/fusion/scripts/DS2-services/leftMenuServiceDS2.js"></script>
    <script src="app/fusion/scripts/DS2-services/manifestService.js"></script>

    <script src="app/fusion/scripts/DS2-directives/footer.js"></script>
    <script src="app/fusion/scripts/DS2-directives/ds2Header.js"></script>
    <script src="app/fusion/scripts/DS2-directives/ds2LeftMenu.js"></script>
    <script src="app/fusion/scripts/DS2-directives/b2b-leftnav-ext.js"></script>
    <script src= "app/fusion/scripts/DS2-services/userInfoServiceDS2.js"></script>

    <!-- Page specific items -->
    <script src="app/fusion/scripts/myapp/myfirstpage/controller.js"></script>
    <script src="app/fusion/scripts/myapp/myfirstpage/route.js"></script>
    <script src="app/fusion/scripts/myapp/myfirstpage/data-service.js"></script>

      .controls {
        margin-bottom: 20px;
      .page-header {
        margin-top: 20px;
      ul {
        list-style: none;
      .box {
        height: 100%;
        border: 1px solid #ccc;
        background-color: #fff;
        position: relative;
        overflow: hidden;
      .box-header {
        background-color: #eee;
        padding: 0px 0px 0px 0px;
        margin-bottom: -25px;
        cursor: move;
        position: relative;
      .box-header h3 {
        margin-top: 0px;
        display: inline-block;
      .box-content {
        padding: 10px;
        height: 100%;
        position: relative;
      .box-header-btns {
        top: 15px;
        right: 10px;
        cursor: pointer;
        position: absolute;
      .gridster {
        border: none;
      .box-content .box-content-frame{
      .box table{
      .box table tr{
      .box table th{
      .handle-e {
  <body class="appBody" ng-app="abs">
    <!-- commented the header for now to avoid duplicate headers on portal -->
    <div ds2-Header class="header-container" ></div>
    <div ds2-menu id="menuContainer" class="menu-container"></div>
    <div ng-view id="rightContentProfile" class="content-container"></div>
    <div ds2-Footer class="footer-container"></div>


sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/app.js contains a single line:

var appDS2=angular.module("abs", ['ngRoute', 'ngMessages','modalServices', 'ngCookies', 'b2b.att','gridster','ui.bootstrap','ui.bootstrap.modal']);

Don’t worry too much about the particulars here. Just know that the list of strings are dependencies. You might add or remove some later.


The controller is where most of the action happens. The controller is complex, but there is one basic thing that needs clarifying. In AngularJS, $scope essentially says, “This should be visible inside the associated template.html.” You’ll gradually come to understand other aspects of the controller as you work with it.

Copy and paste the following into sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/controller.js:

  .controller('myFirstPageController', function($scope, $routeParams, $location, $interval, $http, $q, $modal, $log, ManifestService, dataService) {

    $scope.init = function () {
      // Set up and initialize a state object. This object will contain information about the state of
      // the application as the user interacts with it.
      $scope.state = {
        // Holds a message string for testing
        message: "Hello from myFirstPageController",

     * Setup and initialize the app on load


  }); // end .controller


data-service.js is the bridge between the Java side of your app and the web side. The dataService makes http requests to Once a response is received (it will not block, waiting for a response, because you want your app to continue working while waiting), it executes the then portion of the code, which simply returns the result back to wherever it was called from.

We’ll see it in action soon. For now copy and paste the following into sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/data-service.js:

appDS2.factory('dataService', function ($http, $q, $log) {
  return {
    // Service to return chart data
    getChartData: function(direction) {
      return $http.get("get_chart_data/" + direction + "/").then(function(response) {
        if (typeof === 'object' || typeof === 'string') {
        else {
          return $q.reject(;
      }, function(response) {
        return $q.reject(;


route.js tells AngularJS how to map specific kinds of incoming requests to specific pages and controllers. AngularJS uses the ‘location’ hashtag to pass parameters to the client as seen in the commented when block example below.

Copy and paste the following into sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/route.js:

appDS2.config(function($routeProvider) {

  // Example route that maps a specific URL to another page and
  // controller.
  // This would respond to:
  //    http://localhost:8080/epsdk-app-os#/date1/2017-08-01/date2/2017-08-07/
  //.when('/date1/:date1/date2/:date2/', {
  //  templateUrl: 'app/fusion/scripts/myapp/myfirstpage/someotherpage.html',
  //  controller : "anotherController"

    templateUrl: 'app/fusion/scripts/myapp/myfirstpage/template.html',
    controller : "myFirstPageController"


The AngularJS template holds all the HTML and AngularJS directives that are presented to the user inside the ONAP Portal SDK boilerplate navigation. It is referenced in the route.js file. Copy and paste the following into sdk/ecomp-sdk/epsdk-app-os/src/main/webapp/app/fusion/scripts/myapp/myfirstpage/template.html:

<div id="page-content" class="content" style="padding: 25px;">

Now, compile, install, and login.

Adding your new page to the SDK navigation

First, click on Menus in the Admin navigation menu:


Now, click the Add Menu Item button at the top of the page:


Finally, fill out the form in the following way.


“myfirstpage” is a reference to the name we defined in Request routing via definitions.xml.


To reload the navigation, click Home in the Portal SDK navigation menu. You should see your new menu item at the top. If all went well, you should see “Hello from myFirstPageController” in the content area to the right of the navigation menu.