maincontroller.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. app.controller("MainController", function($scope, $http){
  2. $scope.understand = "I now understand how the scope works!";
  3. $scope.inputValue = "Hi Sanjoy !";
  4. $scope.selectedPerson = 0;
  5. $scope.selectedGenre = null;
  6. $scope.people = [
  7. {
  8. id: 0,
  9. name: 'Leon',
  10. music: [
  11. 'Rock',
  12. 'Metal',
  13. 'Dubstep',
  14. 'Electro'
  15. ]
  16. },
  17. {
  18. id: 1,
  19. name: 'Chris',
  20. music: [
  21. 'Indie',
  22. 'Drumstep',
  23. 'Dubstep',
  24. 'Electro'
  25. ]
  26. },
  27. {
  28. id: 2,
  29. name: 'Harry',
  30. music: [
  31. 'Rock',
  32. 'Metal',
  33. 'Thrash Metal',
  34. 'Heavy Metal'
  35. ]
  36. },
  37. {
  38. id: 3,
  39. name: 'Allyce',
  40. music: [
  41. 'Pop',
  42. 'RnB',
  43. 'Hip Hop'
  44. ]
  45. }
  46. ];
  47. $scope.errors = [];
  48. $scope.msgs = [];
  49. $scope.SignUp = function() {
  50. $scope.errors.splice(0, $scope.errors.length); // remove all error messages
  51. $scope.msgs.splice(0, $scope.msgs.length);
  52. $http.post('http://localhost/service/tracywith/home/angular_js', {'username': $scope.username, 'userpassword': $scope.userpassword, 'useremail': $scope.useremail}
  53. ).success(function(data, status, headers, config) {
  54. if (data == '1') {
  55. $scope.msgs.push("Thanks! You have Registered Successfully!");
  56. } else {
  57. $scope.errors.push("Error Occured while saving into Database");
  58. }
  59. }).error(function(data, status) { // called asynchronously if an error occurs
  60. // or server returns response with an error status.
  61. $scope.errors.push(status);
  62. });
  63. }
  64. });