0
I have these 2 models, and the book has a list of language-like objects.
Model book
import { Language} from "./language";
export class Book {
id: number;
name: string;
language: Array<Language>;
}
Model language
export class Language{
id: number;
name: string;
}
Quando tento criar o objeto livro e adicionar uma linguagem na sua listagem de linguagens, tenho erro de undefined:
myBook: Book();
myLanguage: Language();
hello() {
this.myLanguage = new Language();
this.myLanguage.id = 1;
this.myLanguage.name = "portuguese";
this.myBook = new Book();
this.myBook.id = 1;
this.myBook.name = "one book";
this.myBook.language.push(this.myLanguage); //error - undefined
}
Would need some different kind of statement for that listing?
Thank you.
That was it, thank you !
– Sabrina