Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a form to submit data to database. first time when page is loaded it is working fine. but after first submit when we click submit for second vale then console said bad request. this is because all the value are null in $scope.

when i debugging js step by step then again its working.

How to fix this issue.

JavaScript
$scope.Save = function () {
        
        var MainMenuRecord =
            {
                MainMenuId: $scope.Form.MainMenuId,
                MainMenu: $scope.Form.MainMenu,
                PageTitle: $scope.Form.PageTitle,
                PageUrl: $scope.Form.PageUrl,
                MainMenuOrder: $scope.Form.MainMenuOrder,
                UpperText: $scope.Form.UpperText,
                LowerText: $scope.Form.LowerText,
                UpperStatus: $scope.Form.UpperStatus,
                LowerStatus: $scope.Form.LowerStatus,
                HomePanelStatus: $scope.Form.HomePanelStatus,
                PageId: $scope.Form.PageId
            };
        var promisePost = MainMenuService.post(MainMenuRecord);
        promisePost.then(function (pl) {
            alert('Mainmenu ' + pl.statusText + ' Successfully.');
            Clear();
            $scope.Form.pageNumber = 1;
            LoadRecord();
            console.log(pl.data);
           
        }, function (err) {
            console.log("Err" + err.Message);
        });
       
    }


and service is


JavaScript
app.service('MainMenuService', function ($http) {

    //create new record
    this.post = function (tblmainmenu) {
        var request = $http({
            method: "post",
            url: "/api/MainMenuAPI",
            data: tblmainmenu
        });
        return request;
    }
}
Posted
Updated 1-Jul-15 7:03am
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900