header.js

angular.module('homepage').
directive('header', function () {
    return {
    	controller: 'HeaderController',
        restrict: 'E',
        replace: true,
        transclude: true,
        templateUrl: 'components/content-components/header/header.html'
    };
}).
controller('HeaderController', function ($scope, $state, $rootScope, $window, Authentication) {
    $scope.loadDefaultPage = function () {
        if($rootScope.currentRoute.name == "demo") {
            $state.go("start");
        }
        else if($rootScope.isAuthenticated) {
            $window.location.href = '/#/home';
        }
        else {
            $state.go("start");
        }
    };
});