src/app/classes.ts
Helper for building a reactive form. Used to create the {@link FormGroup} and {@link FormControl}s needed for both the {@link OptionsViewComponent} and the options on each {@link IssueContainerComponent}.
Properties |
Methods |
constructor(options: )
|
||||||
|
Defined in src/app/classes.ts:14
|
||||||
|
Constructor
Parameters :
|
| options |
options:
|
Type : []
|
Default value : []
|
|
Defined in src/app/classes.ts:14
|
|
Options to build the form from. |
| toGroup |
toGroup()
|
|
Defined in src/app/classes.ts:27
|
|
Takes the provided options and puts them into a new {@link FormGroup}.
Returns :
any
|
import { FormControl, Validators, FormGroup } from '@angular/forms';
/**
* Helper for building a reactive form. Used to create the
* {@link FormGroup} and {@link FormControl}s needed for
* both the {@link OptionsViewComponent} and the options on
* each {@link IssueContainerComponent}.
*/
export class OptionModel {
/**
* Options to build the form from.
*/
options = [];
/**
* Constructor
* @param options Options to build the form from.
*/
constructor(options) {
this.options = options;
}
/**
* Takes the provided options and puts them into a new {@link FormGroup}.
*/
toGroup() {
const group: any = {};
this.options.forEach((option) => {
if (option.required) {
group[option.key] = new FormControl('', Validators.required);
} else {
group[option.key] = new FormControl('');
}
});
return new FormGroup(group);
}
}