Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
Ionic 2 Variable isn't showing in view

I'm having some trouble with Angular 2(I'm new at it). My Ionic app doesn't recognize my array. Whenever I try to access the properties from may arry or object, ionic 2 says that my variable is empty. This is my code: enter image description here My "view":

And this is my controller showItem.ts:

enter image description here

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Try giving your book type of any see if your data get assigned to book first:

book: any = [];

Also when you pushing data into book, try using this.book instead of passing the this into the function.

this.book.push({id:obj.id, title: obj.title, imagem: obj.imagem});
over 4 years ago · Santiago Trujillo Relatório

0

The problem was into my provider. Actually, it's kinda of a bug that I have to cast into just one object. My json was returning a Object Inside a object. I solved this problem by casting my res.json() into my object name: "book". Like this: res.json()['book']


    buscarLivro(id)
    {
      if (this.dataBook) 
      {
        return Promise.resolve(this.dataBook);
      }
      // Dont have the data yet
      return new Promise(resolve => {
        this.http.get('http://localhost:8000/api/books/'+id)
          .map(res => res.json()['book'])
          .subscribe((data: any) => {
            this.dataBook = data;
            resolve( this.dataBook);
          });
      });
    }

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda