How to display JS objects in the view

0

There is already a question from our friend Vinicius Scaramel with this problem, but there is no solution answer, so come on:

I'm bringing an object in the format JSON via http.get to Ionic , (using AngularJS), but when it is displayed in view with {{}} it only displays [object Object] , not exhibit my object itself ... I'm already losing my hair trying to solve. Let's go to the code:

My provider role that gives GET

 getChamadoSelecionado(){
    return this.http.get(this.LINK + "/chamadoSelecionado");
  }

My array getting my object through GET

ionViewDidLoad() { //funcao que é executada quando abre a view
  console.log('ionViewDidLoad ChamadoPage');
  this.ChamadosProvider.getChamadoSelecionado().subscribe(    // chamando minha funcao que da o GET na minha api, e retorna o objeto
    data => {
      const objeto_retorno = JSON.parse((data as any)._body); // inserindo na variavel os dados que preciso que estão em data._body (convertido em objeto atraves do JSON.parse)
      this.objetoChamadoSelecionado = objeto_retorno;   //atribuindo o objeto ao meu array
      console.log(this.objetoChamadoSelecionado);    
      }, error => {
        console.log(error);
      })
    }

So far everything is running really well, giving a console.log in my variable that received the return of JSON it's beautiful:

CodeofmyView

<ion-header><ion-navbar><ion-title>Chamado</ion-title></ion-navbar></ion-header><ion-contentpadding><div><p>{{objetoChamadoSelecionado}}</p></div></ion-content>

Thisiswhereitshoulddisplaymyobject,butitdisplaysonlythis

I've tried it already

  

objectChooseSelected.number

For example, and I can not get anything ... The strangest of all is that on another page I have a return from a list of objects, using a * ngFor function ...

    
asked by anonymous 22.09.2017 / 17:12

1 answer

0

You even answered your question in the final rs, just use the * ngFor:

<ion-list>
<ion-item *ngFor="let item of objetoChamadoSelecionado">
      <div ><p>{{ item.numero }}</p></div>
</ion-item>
</ion-list>
    
27.09.2017 / 16:16