Why it's pass null in model variable? Where is mistake?
Controller:
[HttpGet]
[AllowAnonymous]
public JsonResult LoginAngular(LoginViewModel model, string returnUrl)
{
Console.WriteLine(model.UserName);
return Json(model.UserName,JsonRequestBehavior.AllowGet);
}
Angular:
var login = angular.module('LoginApp', []);
login.controller('LoginCtrl', function ($scope, $http) {
$scope.name = 'Login';
$scope.model = { UserName: 'nothing', Password: 'nothing' };
$scope.model.UserName = "Test";
$scope.model.Password = 'Test';
$scope.returnUrl = '/Account/TestLogin';
$scope.onClick = function () {
console.log($scope.model);
$http({
method: 'GET',
url: '/Account/LoginAngular',
params: { model: $scope.model, returnUrl: $scope.returnUrl }
}).success(function (response) {
console.log(response);
});
};
});
