Create a custom type
Opened this issue · 4 comments
web-dave commented
- Take a look at one Book Object Link
- Generate a interface
custom-types
- Define two interface in this file
- Use this interface as a type whenever we handle Books
web-dave commented
generate
ng g interface books/shared/custom-types
web-dave commented
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
e.g.
books: IBook[];
@Input() book: IBook;
web-dave commented
getBooks() {
const url = this.restRoot;
return this.http.get<IBook[]>(url);
}