text: var app=angular.module('exampleApp', ['ui.router', 'ngCookies', 'exampleApp.services','ui.bootstrap']);
  var TICKET_APP="http://localhost:8082/Ticket/rest";
    app .config(
          [ '$locationProvider', '$httpProvider', function ( $locationProvider, $httpProvider) {
  
             /* $routeProvider.when('/create', {
                  templateUrl: 'partials/create.html',
                  controller: CreateController
              });
  
              $routeProvider.when('/edit/:id', {
                  templateUrl: 'partials/edit.html',
                  controller: EditController
              });
  
              $routeProvider.when('/login', {
                  templateUrl: 'partials/login.html',
                  controller: LoginController
              });
              $routeProvider.when('/viewticket', {
                  templateUrl: 'partials/viewticket.html'
                
              });
              $routeProvider.otherwise({
                  templateUrl: 'partials/index.html',
                  controller: IndexController
              });/
  
              $locationProvider.hashPrefix('!');
  
              /* Register error provider that shows message on failed requests or redirects to login page on
               * unauthenticated requests */
              $httpProvider.interceptors.push(function ($q, $rootScope, $location) {
                      return {
                          'responseError': function (rejection) {
                              var status = rejection.status;
                              var config = rejection.config;
                              var method = config.method;
                              var url = config.url;
  
                              if (status == 401) {
                                  $location.path("/login");
                              } else {
                                  $rootScope.error = method + " on " + url + " failed with status " + status;
                              }
  
                              return $q.reject(rejection);
                          }
                      };
                  }
              );
  
              /* Registers auth token interceptor, auth token is either passed by header or by query parameter
               * as soon as there is an authenticated user */
              $httpProvider.interceptors.push(function ($q, $rootScope, $location) {
                      return {
                          'request': function (config) {
                              var isRestCall = config.url.indexOf('rest') == 0;
                              if (isRestCall && angular.isDefined($rootScope.accessToken)) {
                                  var accessToken = $rootScope.accessToken;
                                  if (exampleAppConfig.useAccessTokenHeader) {
                                      config.headers['X-Access-Token'] = accessToken;
                                  } else {
                                      config.url = config.url + "?token=" + accessToken;
                                  }
                              }
                              return config || $q.when(config);
                          }
                      };
                  }
              );
  
          }]
      ).run(function ($rootScope, $location, $cookieStore, UserService) {
  
      /* Reset error when a new view is loaded */
      $rootScope.$on('$viewContentLoaded', function () {
          delete $rootScope.error;
      });
  
      $rootScope.hasRole = function (role) {
  
          if ($rootScope.user === undefined) {
              return false;
          }
  
          if ($rootScope.user.roles[role] === undefined) {
              return false;
          }
  
          return $rootScope.user.roles[role];
      };
  
      $rootScope.logout = function () {
          delete $rootScope.user;
          delete $rootScope.accessToken;
          $cookieStore.remove('accessToken');
          localStorage.clear();
          $location.path("/login");
      };
  
      /* Try getting valid user from cookie or go to login page */
      var originalPath = $location.path();
      $location.path("/login");
      var accessToken = $cookieStore.get('accessToken');
      if (accessToken !== undefined) {
          $rootScope.accessToken = accessToken;
          UserService.get(function (user) {
              $rootScope.user = user;
              $location.path(originalPath);
          });
      }
  
      $rootScope.initialized = true;
  });
  
  function IndexController($scope, BlogPostService) {
  
      $scope.blogPosts = BlogPostService.query();
  
      $scope.deletePost = function (blogPost) {
          blogPost.$remove(function () {
              $scope.blogPosts = BlogPostService.query();
          });
      };
  }
  
  function EditController($scope, $routeParams, $location, BlogPostService) {
  
      $scope.blogPost = BlogPostService.get({id: $routeParams.id});
  
      $scope.save = function () {
          $scope.blogPost.$save(function () {
              $location.path('/login');
          });
      };
  }
  
  function CreateController($scope, $location, BlogPostService) {
  
      $scope.blogPost = new BlogPostService();
  
      $scope.save = function () {
          $scope.blogPost.$save(function () {
              $location.path('/login');
          });
      };
  }
  
  function LoginController($scope, $rootScope, $location, $cookieStore, UserService) {
  
      $scope.rememberMe = false;
  
      $scope.login = function () {
  		
  		
  		console.log($scope.username);
  		console.log($scope.password);
  		
  		
          UserService.authenticate($.param({
              username: $scope.username,
              password: $scope.password
          }), function (authenticationResult) {
  			
  			console.log(authenticationResult);
  			
              var accessToken = authenticationResult.token;
              $rootScope.accessToken = accessToken;
              if ($scope.rememberMe) {
                  $cookieStore.put('accessToken', accessToken);
              }
              UserService.get(function (user) {
                  $rootScope.user = user;
                  $location.path("/login");
              });
          });
      };
  }
  
  var services = angular.module('exampleApp.services', ['ngResource']);
  
  services.factory('UserService', function ($resource) {
  
      return $resource('rest/user/:action', {},
          {
              authenticate: {
                  method: 'POST',
                  params: {'action': 'authenticate'},
                  headers: {'Content-Type': 'application/x-www-form-urlencoded'}
              }
          }
      );
  });
  
  services.factory('BlogPostService', function ($resource) {
  
      return $resource('rest/blogposts/:id', {id: '@id'});
  });
  