angular.module('myApp')
  .controller('LoginCtrl', function($scope, Auth, $location, $rootScope, $sessionStorage) {
    $scope.user = {
      username: 'admin',
      password: 'admin123'
    };
    $scope.authenticateUser = function() {
      Auth.login($scope.user.username, $scope.user.password)
        .success(function(data) {
          if (data.token) {
            $rootScope.userDetail = data.userDetail;
            $sessionStorage.userDetail = $rootScope.userDetail;
          }
        });
    };
  });

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js