I am working with the following model classes:
export class Book {
public name: string;
public id: string;
...
}
export class Author {
public firstName: string;
public lastName: string;
...
}
The my-component
triggers an event that utilizes objects of the aforementioned classes
this.archiveEntry.emit({ book: this.book, author: this.author });
The parent component in its HTML file includes my-component
as shown below
<my-component (archiveEntry)="archiveEntryHandler($event)" ...> ...
and attaches the following handler to this event
public archiveEntryHandler({book: Book, author: Author}) {
let line = `"${book.name}", ${author.lastName}`;
...
}
however, I encounter the following compilation errors
error TS2552: Cannot find name 'book'. Did you mean 'Book'?
error TS2552: Cannot find name 'author'. Did you mean 'Author'?
How can I properly destructure the event parameter/s in the handler?