Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. angular.module('starter.controllers', [])
  2.  
  3.  
  4.  
  5.  
  6. .controller('AppCtrl', function($scope, $rootScope, $window, $ionicModal, $timeout, authService, $state, $http, $ionicLoading, $location) {
  7. //$window.location.reload();
  8.  
  9. $scope.loginSubmitted = false;
  10. $scope.myflag = false;
  11. $scope.User = {};
  12. $scope.toast = function() {
  13. $ionicLoading.show({
  14. template: 'wrong credentials'
  15. });
  16. $timeout(function() {
  17. $ionicLoading.hide();
  18. }, 1000);
  19. }
  20. $scope.footerflag = true;
  21. $scope.hidefooter = function() {
  22. $timeout(function() {
  23. $scope.footerflag = false;
  24. },1)
  25. }
  26. $scope.showfooter = function() {
  27. $timeout(function() {
  28. $scope.footerflag = true;
  29. },1)
  30. }
  31.  
  32.  
  33. $scope.doLogin = function() {
  34. console.log("trying login");
  35.  
  36. // // var res = $http.post('http://login.com/postLogin', $scope.user);
  37. // authService.postdetails($scope.User).success(function(data, status, headers, config) {
  38. // $scope.message = data;
  39. // console.log("succesfn");
  40. // console.log(status);
  41. //
  42. // })
  43. // .error(function(data, status, headers, config) {
  44. // alert("failure message: " + JSON.stringify({
  45. // data: data
  46. // }));
  47. // console.log(fail);
  48. // });
  49. $scope.loginSubmitted = true;
  50. $scope.loginstatus = 0;
  51. authService.GetByUsername().success(function(data) {
  52. $scope.UserData = data;
  53. // console.log($scope.UserData);
  54. for (var i = 0; i < $scope.UserData.length; i++) {
  55. if ($scope.UserData[i].UserName == $scope.User.UserName && $scope.UserData[i].Password == $scope.User.Password) {
  56. authService.currentuser = $scope.User.UserName;
  57. //console.log(authService.currentuser);
  58. $scope.loginstatus = 1;
  59. break;
  60. }
  61. }
  62. if ($scope.loginstatus == 1) {
  63.  
  64. // var lastVal = $cookieStore.get($scope.User.UserName);
  65. // console.log(lastVal);
  66. //$location.path('/app/playlists');
  67. $scope.loginstatus = 0;
  68. $state.go('app.playlists', null, {
  69. reload: true
  70. });
  71. } else {
  72. console.log('wrong credentials');
  73. $scope.toast();
  74. }
  75.  
  76. }).error(function(err) {
  77. console.log(err);
  78. });
  79.  
  80.  
  81. }
  82.  
  83.  
  84.  
  85. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement