30 lines
690 B
TypeScript
30 lines
690 B
TypeScript
|
import { BaseModel } from '../BaseModel';
|
|||
|
import { FormGroup } from '@angular/forms';
|
|||
|
import { FormGenerator } from '../interfaces/FormGenerator';
|
|||
|
import { Serializable } from '../interfaces/Serializable';
|
|||
|
|
|||
|
export class Page extends BaseModel implements Serializable<Page>, FormGenerator<FormGroup>{
|
|||
|
public title: string;
|
|||
|
public id: number;
|
|||
|
|
|||
|
constructor(id?: number) {
|
|||
|
super();
|
|||
|
if (isNaN(id)) this.id = 0;
|
|||
|
else this.id = id;
|
|||
|
}
|
|||
|
|
|||
|
fromJSONObject(item: any): Page {
|
|||
|
this.title = item.title;
|
|||
|
this.id = item.id;
|
|||
|
return this;
|
|||
|
}
|
|||
|
|
|||
|
buildForm(): FormGroup {
|
|||
|
let formGroup = this.formBuilder.group({
|
|||
|
title: [this.title],
|
|||
|
id: [this.id]
|
|||
|
|
|||
|
});
|
|||
|
return formGroup;
|
|||
|
}
|
|||
|
}
|