Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sören Deger 733 posts 2844 karma points c-trib
    Mar 05, 2015 @ 04:27
    Sören Deger
    0

    AngularJS Object is empty in release mode

    Hi,

    I have a very strange behavior If I change from debug to release mode in Visual Studio.

    I have a resource file, which calls a UmbracoAuthorizedJsonController. This Controller give me as response a object with informations about all document types via ContentTypeService.

    It works great in debug mode. But if i change to release mode the angularJS object from my response is empty.

    This is the result in debug mode:

    [{"id":0,"alias":"0","name":"[Choose a document type]"},{"id":1878,"alias":"AboutUs","name":"About us"},{"id":1879,"alias":"Contact","name":"Contact"},{"id":1877,"alias":"Faq","name":"FAQ"},{"id":1876,"alias":"FaqArea","name":"FAQ Area"},{"id":1872,"alias":"Homepage","name":"Homepage"},{"id":1342,"alias":"mail2cms_autodatefolders","name":"mail2cms_AutoDateFolders"},{"id":2168,"alias":"mail2cms_email","name":"mail2cms_email"},{"id":1345,"alias":"mail2cmsDayFolder","name":"mail2cmsDayFolder"},{"id":1344,"alias":"mail2cmsMonthFolder","name":"mail2cmsMonthFolder"},{"id":1343,"alias":"mail2cmsYearFolder","name":"mail2cmsYearFolder"},{"id":1871,"alias":"Master","name":"Master"},{"id":1875,"alias":"News","name":"News"},{"id":1874,"alias":"NewsCategory","name":"News Category"},{"id":1882,"alias":"parserErrors","name":"Parser Errors"},{"id":1881,"alias":"Product","name":"Product"},{"id":1880,"alias":"Products","name":"Products"}]

     

    But this is the result in release mode:

    [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]

     

    This is my code in angularJS resource file:

    angular.module("umbraco.resources")
    .factory("mappingResource", function ($http) {
       return {
           getAll: function () {
               var allDocTypes = $http.get("Backoffice/mail2CMS/MappingApi/GetAllDocTypes").then(function (response) {
                   console.log(JSON.stringify(response.data));
                   return response.data;
               });
               return allDocTypes;
           },
    };


    Have anyone an explanation for this behavior or a solution for this?

    Best,

    Sören

  • Sören Deger 733 posts 2844 karma points c-trib
    Mar 05, 2015 @ 06:40
    Sören Deger
    101

    Ok, I found the error. The behavior came not from the resource file, but from UmbracoAuthorizedJsonController. The result of the method in controller was of type object. Now I have defined a concrete class instead of 'object' and use these and all works good in release mode.

    Although I am still not entirely clear why this with objects only in debug mode works, but this was at least the cause.

     

    Sören

Please Sign in or register to post replies

Write your reply to:

Draft