Remove ↵ from JSON in web api + AngularJS

I use the web API 2 + AngularJS to return my data to angular controllers, but I don't know why I keep getting this character as a result of my json.

My ASP controller has this method.

public IHttpActionResult GetAditionalFieldCOnfiguration()
    {
        var ListAdditionalFields = new List<rgAdditionalField>() 
        { 
            new rgAdditionalField(){  Type="text", Label="Nombre", Model="first", Val="Carlo" },
            new rgAdditionalField(){  Type="text", Label="Apellido", Model="last", Val="Carlos prueba"},
            new rgAdditionalField(){  Type="text", Label="Direc", Model="direccion", Val="los alpes"},
        };

        return Ok(ListAdditionalFields);
    }

and I got this in my angular controller (I tried with $ http, $ resource and Restangular and got the same result):

http://i.imgur.com/LBAn3y3.jpg

I tried different configurations in my WebApiConfig, but nothing works, configuration:

 public static JsonSerializerSettings GetSettingListFormat(rgJsonSettingType type)
    {

        switch (type)
        {
            case rgJsonSettingType.List:
                return new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.None, ReferenceLoopHandling = ReferenceLoopHandling.Ignore };                    
            case rgJsonSettingType.Single:
                return new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects, ReferenceLoopHandling = ReferenceLoopHandling.Ignore };                    
            case rgJsonSettingType.SingleCamelCase:
                return new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects, ContractResolver = new CamelCasePropertyNamesContractResolver() };
            case rgJsonSettingType.ListCamelCase:
                return new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.None, ReferenceLoopHandling = ReferenceLoopHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() };

        }

        return new JsonSerializerSettings();
    }

I tried with HttpResponseMessage and it returns:

return   Request.CreateResponse(HttpStatusCode.OK, ListAdditionalFields, JsonConfiguration.....)

and nothing else.

Can you help me?

+4
source share
1 answer

, AngularJS, .

angularjs , , ↵ :

  $scope.hasEnter = function(str) {
        var enter= /\n/gi;
        if (enter.test(str)) {
            return true;
        } else
            return false;
    };

, , .

, .

0

All Articles