text: (function(){
  
    angular
         .module('users')
         .controller('UserController', [
            'userService', 'storeService', '$mdSidenav', '$mdBottomSheet', '$timeout', '$log',
            UserController
         ]);
  
    /**
     * Main Controller for the Angular Material Starter App
     * @param $scope
     * @param $mdSidenav
     * @param avatarsService
     * @constructor
     */
    function UserController( userService, storeService, $mdSidenav, $mdBottomSheet, $timeout, $log  ) {
      var self = this;
  
      self.selected     = null;
      self.users        = [ ];
      self.stores       = null;
      self.selectedStore= null;
      self.selectUser   = selectUser;
      self.toggleList   = toggleUsersList;
      self.makeContact  = makeContact;
      self.change       = false;
  
      // Load all registered users
  
      userService
            .loadAllUsers()
            .then( function( users ) {
              self.users    = [].concat(users);
              self.selected = users[0];
            });
  
      storeService
          .loadAllStores()
          .then( function( stores ){
            self.stores = [].concat(stores);
            self.selectedStore = stores[0].storeNumber;
          })
  
      // *********************************
      // Internal methods
      // *********************************
  
      /**
       * Hide or Show the 'left' sideNav area
       */
      function toggleUsersList() {
        $mdSidenav('left').toggle();
      }
  
      /**
      * Set global Store variable
      */
      function  changeStore () {
  
      }
  
      /**
       * Select the current avatars
       * @param menuId
       */
      function selectUser ( user ) {
        self.selected = angular.isNumber(user) ? $scope.users[user] : user;
      }
  
      /**
       * Show the Contact view in the bottom sheet
       */
      function makeContact(selectedUser) {
  
          $mdBottomSheet.show({
            controllerAs  : "vm",
            templateUrl   : './src/users/view/contactSheet.html',
            controller    : [ '$mdBottomSheet', ContactSheetController],
            parent        : angular.element(document.getElementById('content'))
          }).then(function(clickedItem) {
            $log.debug( clickedItem.name + ' clicked!');
          });
  
          /**
           * User ContactSheet controller
           */
          function ContactSheetController( $mdBottomSheet ) {
            this.user = selectedUser;
            this.items = [
              { name: 'Phone'       , icon: 'phone'       , icon_url: 'assets/svg/phone.svg'},
              { name: 'Twitter'     , icon: 'twitter'     , icon_url: 'assets/svg/twitter.svg'},
              { name: 'Google+'     , icon: 'google_plus' , icon_url: 'assets/svg/google_plus.svg'},
              { name: 'Hangout'     , icon: 'hangouts'    , icon_url: 'assets/svg/hangouts.svg'}
            ];
            this.contactUser = function(action) {
              // The actually contact process has not been implemented...
              // so just hide the bottomSheet
  
              $mdBottomSheet.hide(action);
            };
          }
      }
  
    }
  
  })();
  