web-dave / angular_workshop

0 stars 0 forks source link

Create custom Type #9

Open web-dave opened 7 months ago

web-dave commented 7 months ago
  1. Take a look at one Book Object Link
  2. Generate a interface Book and define it
    book.ts
 export interface IBook {
  id: string;
  title: string;
  subtitle: string;
  isbn: string;
  abstract: string;
  author: string;
  publisher: string;
  price: string;
  numPages: number;
  cover: string;
  userId: number;
}

  1. Use this interface as a type whenever we handle Books
    Types
this.http.get<IBook[]>('http://localhost:4730/books');

@Input() book: IBook | undefined;

books: IBook[] = [];

web-dave commented 5 months ago

NEXT