'use strict';

/**
 * @ngdoc function
 * @name domainManagerApp.controller:MainCtrl
 * @description
 * # MainCtrl
 * Controller of the domainManagerApp
 */
angular.module('domainManagerApp.header', ['domainManagerApp.userData'])
  .controller('HeaderController', ['$scope', '$rootScope', '$location', 'UserData', function ($scope, $rootScope, $location, UserData) {
    $scope.isActive = function (viewLocation) {
        return viewLocation === $location.path();
    };
    $scope.isAuthenticated = UserData.isAuthenticated();

    $rootScope.$on('user:isAuthenticated', function(data, isAuthenticated) {
      // you could inspect the data to see if what you care about changed, or just update your own scope
      $scope.isAuthenticated = isAuthenticated;
      console.log($scope.isAuthenticated)
    });

  }]);