Skip to content

Instantly share code, notes, and snippets.

@olivermt
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivermt/f5b49f85090f575d588d to your computer and use it in GitHub Desktop.
Save olivermt/f5b49f85090f575d588d to your computer and use it in GitHub Desktop.
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