Mahajan344 Mahajan344 - 2 years ago 98
AngularJS Question

model value null when passed from angular post service

I am working on AngularJs with MVC , I am having a silly issue while passing model to MVC controller.

If I Debug the code .. data is there in object till I make ajax post call.. but when I check on controller everything becomes null.

Here is my code


$scope.loginUser = {
email: "",
password: "",
typeofUser: "ExternalUser"

var onLoginComplete = function (data) {

var onError = function (reason) {
$scope.error = "Could not fetch the data.";

DataService.validateUser($scope.loginUser).then(onLoginComplete, onError);

Now DataService

var baseurl = window.location.protocol + "//" + + "/";
var validateUser = function (model) {
return $ + "Account/Login/" + model)
.then(function (response) {

and Model class in MVC

public class LoginViewModel
[Display(Name = "Email")]
public string Email { get; set; }

[StringLength(50, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[Display(Name = "Password")]
public string Password { get; set; }

public string TypeofUser { get; set; }

Now you can below image that before making post call to controller , object has values..
enter image description here

But after going to controller , all values are null

enter image description here

Win Win
Answer Source

Post parameters are not correct. Replace + with ,.

return $ + "Account/Login/", model)

You can read more here.

$'/someUrl', data, config).then(successCallback, errorCallback);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download