Last active
August 29, 2015 14:01
-
-
Save olivermt/f5b49f85090f575d588d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('safariFront.common', ['safariFront.commonServices']) | |
.controller('RegistrationModalController', ['$scope', function($scope) { | |
$scope.companies = {} //will show you new fancy rest thing later | |
}]) | |
.controller('BodyController',['$scope', 'LoginService', function($scope, LoginService) { | |
'use strict'; | |
$scope.topTitle = "Home"; | |
$scope.user = LoginService.getUser(); | |
$scope.login = function() { | |
LoginService.login(); | |
}; | |
$scope.logout = function() { | |
LoginService.logout(); | |
}; | |
$scope.$watch(LoginService.isAuthenticated, function() { | |
$scope.user = LoginService.getUser(); | |
}); | |
$scope.launchRegistrationModal = function() { | |
var modalInstance = $modal.open({ | |
templateUrl: '../page/_register.html', | |
// How do you register a controller so that it's accessible here? | |
controller: 'RegistrationModalController', | |
resolve: { | |
companies: function() { | |
return $scope.companies; | |
} | |
} | |
}); | |
}; | |
}]) | |
.directive('bsNavbar', [ '$location', function($location) { | |
'use strict'; | |
return { | |
restrict: 'A', | |
link: function postLink(scope, element, attrs, controller) { | |
// Watch for the $location | |
scope.$watch(function() { | |
return $location.path(); | |
}, function(newValue, oldValue) { | |
$('li[data-match-route]', element).each(function(k, li) { | |
var $li = angular.element(li), | |
// data('match-rout') does not work with dynamic attributes | |
pattern = $li.attr('data-match-route'), | |
regexp = new RegExp('^' + pattern + '$', ['i']); | |
if(regexp.test(newValue)) { | |
$li.addClass('active'); | |
} else { | |
$li.removeClass('active'); | |
} | |
}); | |
}); | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment