Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda