I am sending a value from Angular to controller which happens to be a string. But it becomes null in the controller. I did this in some other modules as well and everything was fine there. But i am unable to figure out the problem in the below code.. Please help......
This is my Controller:
[HttpPost]
public JsonResult OpenNewDay(string dayopen)
{
string Messege = sessionservice.Newday(dayopen);
return Json(Messege, JsonRequestBehavior.AllowGet);
}
This is my View along with the Angular:
Open Session
<form class="form-inline">
<label class="sr-only">Session Open Date</label>
<input type="text" ng-model="dayopen" readonly="readonly" class="form-control">
<button type="button" ng-click="Save(dayopen)" class="btn btn-default">Open</button>
</form>
<script type="text/javascript">
var day = angular.module("dayModule", []);
day.controller("dayController", function ($scope, $http) {
$scope.Save = function (dayopen) {
alert(JSON.stringify(dayopen));
$http({
method: "POST",
url: "/Session/OpenNewDay",
data: JSON.stringify(dayopen),
}).success(function (data) {
alert(data);
}).error(function (err) {
$scope.Message = err.Message;
})
};
});
</script>