20 lines
610 B
TypeScript
20 lines
610 B
TypeScript
import { FormGenerator } from '../interfaces/FormGenerator';
|
|
import { Serializable } from '../interfaces/Serializable';
|
|
import { FormGroup, FormBuilder } from '@angular/forms'
|
|
export class ListingItem implements Serializable<ListingItem>, FormGenerator<FormGroup>{
|
|
public label: string;
|
|
public value: string;
|
|
|
|
fromJSONObject(item: any): ListingItem {
|
|
this.label = item.label;
|
|
this.value = item.value;
|
|
return this;
|
|
}
|
|
|
|
buildForm(): FormGroup {
|
|
return new FormBuilder().group({
|
|
label: [this.label],
|
|
value: [this.value]
|
|
})
|
|
}
|
|
} |