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