web-dave / Angular-Essentials-Training

9 stars 0 forks source link

Create a custom type #13

Open web-dave opened 6 years ago

web-dave commented 6 years ago
web-dave commented 6 years ago

generate

  ng g interface books/shared/custom-types
web-dave commented 6 years ago

custom-types.ts

export interface IBook {
  title: string;
  subtitle: string;
  isbn: string;
  abstract: string;
  numPages: number;
  author: string;
  publisher: IUser;
}

export interface IUser {
  name: string;
  url: string;
}
web-dave commented 6 years ago

e.g.

  books: IBook[];
  @Input() book: IBook;
web-dave commented 6 years ago

  getBooks() {
    const url = this.restRoot;
    return this.http.get<IBook[]>(url);
  }
web-dave commented 6 years ago

Show Book Details