I can print the entire object but not an element of the object js

2

I'm working on Angular. Through a Factory I send an object to the Controller and I want to work with that object but I can not access the elements of the object, but if I make a console.log () of the object, then it shows me all the data.

Please note that SRConsulta is the Factory, in the image below it prints me the whole object correctly but when wanting to access the value: "building", it comes out as undefined

This is the Factory code:

.factory('SRConsulta', function(SalasReunionesInstancia, SalasReunionesAreas, SalasReunionesEdificios, SalasReunionesPisos, Contactos, $rootScope, UserPermission) {
var r = {};
r.permisos = {};
var usuario = UserPermission.findByName({username: $rootScope.username}, function(usuario) {
    if(usuario.edificio) {
        r.permisos.edificio = usuario.edificio;
    }

    if(usuario.piso) {
        r.permisos.piso = usuario.piso;
    }
});

return r;

});

Does anyone know? Thanks

    
asked by Chiiviito 17.01.2018 в 16:02
source

0 answers