Send form input to Controller with angularjs

0

I need to send the form's input collection to the MVC controller method (C #) by means of an ajax request from an Angular controller, the problem is that the FormCollection arrives empty to the controller. p>

How can I send the serialized form using angularJS?

It's a view with dynamically generated controls and I do not use a ViewModel I need the FormControll collection.

<input="button" ng-click="submit()" />

//submit Angular controlador:
$scope.submit = function () {
$http({
        url: '/Tickets/Update',
        method: "POST",
        data: --> aqui el formulario serializdo JSON

    })
    .success(function (data, status, headers, config) {

    }).error(function (data, status, headers, config) {

    });
}

Thanks

    
asked by Kram_ 25.08.2016 в 15:10
source

1 answer

1

You should not use the FormCollection if you use angular, you are supposed to generate a json that maps with the parameter that you define in the action, in this way the DataBinding will do the rest, if the json property maps with the property of the model class will assign the value.

AngularJS $ http service in an ASP.NET MVC app

The idea is that from angular you have a json that represents the model of the view that you can binde the controls of the view and thus be able to keep the data synchronized.

Then you take this and send it to a service that will use $http to send in the post this json to action

All this you will observe in the article that I suggest, but the FormCollection is not used at all

    
answered by 25.08.2016 в 16:19