Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. app.controller('CustSignupCtrl', ['$scope', '$filter','frontendService', '$http', 'editableOptions', 'editableThemes','notify','notification','$appConstants',
  2. function('$scope', '$filter','frontendService', '$http','editableOptions', 'editableThemes','notify','notification','$appConstants'){
  3.  
  4.  
  5. $scope.pw1 = '';
  6.  
  7. $scope.registerCustomer = function (data) {
  8. return frontendService.registerCust(data)
  9. }
  10.  
  11. $scope.signupcustomer = function(){
  12.  
  13. var payload= {
  14. first_name: $scope.custForm.fname,
  15. last_name: $scope.custForm.lname,
  16. phone: $scope.custForm.phone,
  17. email:$scope.custForm.email,
  18. username:$scope.custForm.username,
  19. password:$scope.custForm.pw1,
  20. usertype:3
  21. }
  22. console.log("inside function");
  23. $scope.registerCustomer(payload).then(function(data){
  24. notification.success(data.result);
  25. },function(err){
  26. notification.error("Error: contact system admin");
  27. });
  28.  
  29.  
  30. }
  31. }
  32. ])
  33.  
  34. app.service('frontendService', function frontendService ($http, $q){
  35.  
  36. // name of the service taking current scope
  37. var list = this;
  38.  
  39.  
  40. list.registerCust = function(data){
  41. var defer = $q.defer();
  42.  
  43. $http({
  44. url: 'http://139.59.252.34:3000/user/create',
  45. method: "POST",
  46. data: data
  47. })
  48. .success(function(res){
  49. console.log("Successfull!");
  50. defer.resolve(res);
  51. })
  52. .error(function(err, status){
  53. console.log("Failed !");
  54. })
  55.  
  56. return defer.promise;
  57. }
  58.  
  59. return list;
  60.  
  61. });
  62.  
  63. app.controller('CustSignupCtrl', ['$scope', '$filter','frontendService', '$http', 'editableOptions', 'editableThemes','notify','notification','$appConstants',
  64. function($scope, $filter,frontendService, $http,editableOptions, editableThemes,notify,notification,$appConstants){
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement