Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. var wc = angular.module('wc', ['ui.router', 'am.multiselect', 'angularUtils.directives.dirPagination', 'ui.bootstrap', 'ui.bootstrap.datetimepicker', 'LocalStorageModule']);
  2.  
  3. wc.config(function ($stateProvider, $urlRouterProvider) {
  4. $urlRouterProvider.otherwise('/login');
  5. $stateProvider
  6. .state('login', {
  7. url: '/login',
  8. templateUrl: 'views/login.html',
  9. controller: 'LoginCtrl'
  10. })
  11.  
  12. .state('logout', {
  13. cache: false,
  14. url: '/logout',
  15. templateUrl: 'views/logout.html',
  16. controller: 'LogoutCtrl'
  17. })
  18.  
  19.  
  20. .state('tab', {
  21. url: '/tab/:id',
  22. templateUrl: 'views/tab.html'
  23. });
  24.  
  25. wc.controller('LogoutCtrl', function ($scope, $http, $location) {
  26. $location.path('/tab');
  27. });
  28. wc.controller('LoginCtrl', function ($scope, $http) {
  29. $scope.submit = function () {
  30. $http.get("urlUserName=" + $scope.person.firstName + "&Password=" + $scope.person.pswd)//Sample Url//
  31. .success(function (data, status, headers, config) {
  32. debugger
  33. $scope.tableData = data;
  34. console.log(data)
  35. if (data == 'Exception') {
  36. window.alert('You have entered wrong username or password');
  37.  
  38. }
  39. else $state.go('tab', { id: data.Table[0].UserId });
  40. })
  41. }});
  42.  
  43. <form ng-submit=submit()>
  44. <div class="input-container">
  45. <input type="text" id="Username" ng-model="person.firstName" required="required" />
  46. <label for="Username">Username</label>
  47. <div class="bar"></div>
  48. </div>
  49. <div class="input-container">
  50. <input type="password" id="Password" ng-model="person.pswd" required="required" />
  51. <label for="Password">Password</label>
  52. <div class="bar"></div>
  53. </div>
  54. <div class="submit">
  55. <input type="submit" value="LOGIN">
  56. </div>
  57. </form>
  58.  
  59. <script src="bower_components/js/angular-local-storage.min.js"></script>
  60. var myApp = angular.module('myApp', ['LocalStorageModule']);
  61. myApp.controller('LoginCtrl', function($scope, localStorageService) {
  62. var lsKeys = localStorageService.keys();//to show all values
  63. function submit(key, val) {
  64. return localStorageService.set(key, val); }
  65. function removeItem(key) {
  66. return localStorageService.remove(key); }
  67. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement