上QQ阅读APP看书,第一时间看更新
The model
The model in Angular is a plain class, as we are using TypeScript. It can look like the following code:
// mvc/MvcExample/src/app/product.model.ts
export class Product {
constructor(
private id: number,
private title: string,
private description: string,
private created: Date
) {}
method() {}
anotherMethod() {}
}
It is a plain TypeScript file, or rather an ES2015 module, not to be confused with an Angular module. We will discuss in the next main section what an Angular module is, in terms of setup and how it is consumed. For now, remember the model is a simple thing.