web-dave / angular-starter-v2

6 stars 3 forks source link

Create a custom type #11

Open web-dave opened 7 years ago

web-dave commented 7 years ago
web-dave commented 7 years ago

generate

  ng g interface books/shared/custom-types
web-dave commented 7 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 7 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);
  }