0

I'm getting data from my backend server

proyecto: Proyecto;
ngOnInit(): void {
// subscribe START
    this.route.paramMap.subscribe(
            params => {
                const id = params.get('id');
                console.log('MainContent:Proyecto Seleccionado: ', id);
                this.dataService.getDatosCabeceraProyecto(id)
                    .subscribe(
                        (data: Proyecto) => this.proyecto = data,
                        (err: any) => console.log(err),
                        () => console.log('MainContent: datos de proyecto recogidos')
                    );
            });
// subscribe END
}

But If I use ngIf directive I don't see anything

html

But I get the data

console

Any idea Please? Thanks

kintela
  • 1,283
  • 1
  • 14
  • 32
  • Use can use this and check as example `
    ` also refer https://stackoverflow.com/a/784946/6923146
    – Hardik Masalawala Feb 11 '21 at 17:20
  • what you have written should work. I would add "data" to your console log to confirm what you are getting. `console.log(data);` It's possible this.proyecto is still null after your service completes. – Rick Feb 11 '21 at 19:03

2 Answers2

0

Try checking with some data inside the result with *ngIf and see if u get the results first .

For eg -

*ngIf="proyecto.ID==X000128" 

This will give you an idea of what it accepts .

angular_code
  • 319
  • 3
  • 18
0

Use can use this and check as example

<div *ngIf="!!proyecto">

reference use of !! Operator

Ref: https://stackoverflow.com/a/784946/6923146