February 2019
Beginner
694 pages
18h 4m
English
The Model in MVC represents data. This is generally a very simple Plain Old JavaScript Object (POJO) that has certain properties. As an example of a Model, consider the following TypeScript class:
interface IModel {
DisplayName: string;
Id: number;
}
class Model implements IModel {
DisplayName: string;
Id: number;
constructor(model : IModel) {
this.DisplayName = model.DisplayName;
this.Id = model.Id;
}
}
let firstModel = new Model({ Id: 1, DisplayName: 'firstModel'});
Here, we have defined an interface named IModel that has an Id and a DisplayName property, and a class that implements this interface. We have provided a simple constructor to set these properties. The last line of this snippet creates an instance of this class, with ...
Read now
Unlock full access