Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.controller('CustSignupCtrl', ['$scope', '$filter','frontendService', '$http', 'editableOptions', 'editableThemes','notify','notification','$appConstants',
- function('$scope', '$filter','frontendService', '$http','editableOptions', 'editableThemes','notify','notification','$appConstants'){
- $scope.pw1 = '';
- $scope.registerCustomer = function (data) {
- return frontendService.registerCust(data)
- }
- $scope.signupcustomer = function(){
- var payload= {
- first_name: $scope.custForm.fname,
- last_name: $scope.custForm.lname,
- phone: $scope.custForm.phone,
- email:$scope.custForm.email,
- username:$scope.custForm.username,
- password:$scope.custForm.pw1,
- usertype:3
- }
- console.log("inside function");
- $scope.registerCustomer(payload).then(function(data){
- notification.success(data.result);
- },function(err){
- notification.error("Error: contact system admin");
- });
- }
- }
- ])
- app.service('frontendService', function frontendService ($http, $q){
- // name of the service taking current scope
- var list = this;
- list.registerCust = function(data){
- var defer = $q.defer();
- $http({
- url: 'http://139.59.252.34:3000/user/create',
- method: "POST",
- data: data
- })
- .success(function(res){
- console.log("Successfull!");
- defer.resolve(res);
- })
- .error(function(err, status){
- console.log("Failed !");
- })
- return defer.promise;
- }
- return list;
- });
- app.controller('CustSignupCtrl', ['$scope', '$filter','frontendService', '$http', 'editableOptions', 'editableThemes','notify','notification','$appConstants',
- function($scope, $filter,frontendService, $http,editableOptions, editableThemes,notify,notification,$appConstants){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement