Is a reserved word a “filter” in Angular, Javascript or ASP.Net MVC?

I make this call from a service using angularJS for an ASP.Net MVC controller:

$http({
    method: "get",
    url: "ControllerMethod",
    params: {
        param1: param1Value,
        pageNumber:  pageNumber,
        pageSize: pageSize,
        filter: filter
    }
}).success(function (data) {
    callback(data);
}).error(function () {
    alert("Error.");
});

Controller Signature:

public ActionResult GetAssetDepreciationList(
     int pageNumber, int pageSize, int param1, MyFilterType filter)

At startup, as shown, the filter parameter is always null. I have a number of similar methods that work without problems.

When I changed:

 filter: filter

in

anythingElse : filter

It worked as expected. Is a reserved word a “filter”? If so, for which framework (MVC, Javascript or angular)?

+4
source share
1 answer

It looks like your filter has a complex type. MyFilterTypeLook this

, . , ( , MyFilterType POCO) ( JSON) .

, , OData. .NET, Nuget, , , IQueryable.

, - . MyFilterType :filter.

:

. , ... ... : (Need System.Web.Http)

 public ActionResult GetAssetDepreciationList(
      int pageNumber, int pageSize, int param1, [FromUri] MyFilterType filter)

, , ..

params: angular.extend({
                           param1: paramValue,
                           pageNumber: pageNumber,
                           pageSize: pageSize,
                        },filter)

, var filter = {paramA:1,paramB:2,paramC:3};

+2

All Articles