J
J
Jackson7502019-06-26 14:18:07
JavaScript
Jackson750, 2019-06-26 14:18:07

How to generate JSON in AngularJS?

var app1 = angular.module('myApp1', []);
    app1.controller('myCtrl1', function($scope, $http) {
 
        $scope.employees = [];
 
        $scope.employeeForm = {
            empId: 1,
            empPoint: 1001,
            empName:  "lolik"
        };
 
            
 
        $scope.sendData = function () {
 
            var method = "";
            var url = "";
 
                method = "POST";
                url = '/userAdd';
                $scope.employeeForm.empId+4;
                console.log("POST");
 
 
            $http({
                method: method,
                url: url,
                data: angular.toJson($scope.employeeForm),
                headers: {
                    'Content-Type': 'application/json'
                }
            }).then();
        };
 
 
    });

I get null on submit. what's wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question