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.
$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
app.service('MainMenuService', function ($http) {
this.post = function (tblmainmenu) {
var request = $http({
method: "post",
url: "/api/MainMenuAPI",
data: tblmainmenu
});
return request;
}
}