mailApp.js 1.62 KB
'use strict';

/**
 * @ngdoc overview
 * @name newappApp
 * @description
 * # newappApp
 *
 * Main module of the application.
 */
var MakeMailApp = angular
  .module('newApp', [
    'ngAnimate',
    'ngRoute',
    'ngTouch',
    'ui.bootstrap'
  ])
  .config(function ($routeProvider) {
      $routeProvider
      .when('/', {
          templateUrl: 'mailbox/mailbox.html',
          controller: 'mailboxCtrl'
      })
      .when('/send', {
          templateUrl: 'mailbox/mailbox-send.html',
          controller: 'mailSendCtrl'
      }).otherwise({
          redirectTo: '/'
      });
  });


// Route State Load Spinner(used on page or content load)
MakeMailApp.directive('ngSpinnerLoader', ['$rootScope',
    function($rootScope) {
        return {
            link: function(scope, element, attrs) {
                // by defult hide the spinner bar
                element.addClass('hide'); // hide spinner bar by default
                // display the spinner bar whenever the route changes(the content part started loading)
                $rootScope.$on('$routeChangeStart', function() {
                    element.removeClass('hide'); // show spinner bar
                });
                // hide the spinner bar on rounte change success(after the content loaded)
                $rootScope.$on('$routeChangeSuccess', function() {
                    setTimeout(function(){
                        element.addClass('hide'); // hide spinner bar
                    },500);
                    $("html, body").animate({
                        scrollTop: 0
                    }, 500);   
                });
            }
        };
    }
])