Pushing multiple data in an array doesn't work in ionic

Hello, i’m actually trying to push some epub in an array to make them appear in a list in my home page, but when i try to push multiple epub like that this doesn’t while just with one book it work. does anyone have a solution?

export class HomePage {
  books: {}[];
  constructor() {
    let book1 = new Book();
    book1.label = "Moby Dick (unpacked)";
    book1.file =  "../../assets/books/agatha-christie-dix-petits-negres.epub";

    this.books = [];
    let book2 = new Book();
    book2.label = "Moby Dick (.epub)";
    book2.file =  "../../assets/books/moby-dick.epub";
  ionViewDidLoad() {
    console.log('ionViewDidLoad HomePage');
  show(book) {
    console.log('show', book);
    // this.navCtrl.push(BookPage, {
    //   book: book  
    // });

It does work - the problem you have is that the array is books and not book so when your code runs:

it does not know what book is.

1 Like


maybe when you declare an array of book an initialise it like

books: book[] = [];

Best regards, anna-liebt