Skip to content

Instantly share code, notes, and snippets.

@cerkit
Created September 23, 2014 16:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cerkit/bd21e8219a4726915224 to your computer and use it in GitHub Desktop.
Save cerkit/bd21e8219a4726915224 to your computer and use it in GitHub Desktop.
Basic Authentication with AngularJS - Login Dialog directive definition
angular.module('app').directive('loginDialog', function () {
return {
templateUrl: 'app/templates/loginDialog.html',
restrict: 'E',
replace: true,
controller: 'CredentialsController',
link: function (scope, element, attributes, controller) {
scope.$on('event:auth-loginRequired', function () {
console.log("got login event");
element.modal('show');
});
scope.$on('event:auth-loginConfirmed', function () {
element.modal('hide');
scope.credentials.password = '';
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment