A model class describes the data an application works with. A data model can also include a data source that loads and saves data and a repository that lets the application manipulate it. Product classes can be added first, with other classes introduced as features require them. section 5.3.1 section 9.6.1
Product class
A TypeScript Product class can declare optional constructor properties for an identifier, name, category, description, and price. Optional properties are useful when an HTML form populates an object. section 5.3.1
Listing 5.11. The contents of the product.model.ts file in the src/app/model folder
export class Product {
constructor(
public id?: number,
public name?: string,
public category?: string,
public description?: string,
public price?: number) { }
}
View a complete Product class with its optional constructor properties. section 5.3.1
