In my class called ParametrosEscaner
, the structure is as follows:
export enum TiposPixel {
BlancoNegro = 0,
Grises,
Color
};
export class ParametrosEscaner {
tipoPixel: TiposPixel;
resolucion: number;
duplex: boolean;
mostrarInterfaz: boolean;
};
I have a component that is supposed to receive an instance of this class using Input:
@Input() parametrosActuales: ParametrosEscaner = new ParametrosEscaner();
constructor() { }
ngOnInit() {
debugger
if(this.parametrosActuales){
console.log(this.parametrosActuales);
this.interfaz = this.parametrosActuales.mostrarInterfaz;
this.dobleCara = this.parametrosActuales.duplex;
this.tipoSeleccionado = this.valoresEnum()[this.parametrosActuales.tipoPixel];
this.resolucionSeleccionada = this.parametrosActuales.resolucion;
}
}
Despite the console log showing the object properly, all the properties are returning undefined. I'm puzzled as to why this is happening.
EDIT The parent component that sends the object looks like this:
ngOnInit() {
this._informacionPreferencias.preferenciasActuales.subscribe(pref => {
this.preferenciasCargaUsuario = pref;
debugger
if(this.preferenciasCargaUsuario.ParametrosEscaner){
this.parametrosEscaner = this.preferenciasCargaUsuario.ParametrosEscaner;
}
})
}
this.parametrosEscaner
is the object that the child component is supposed to receive