I am developing a system using Angular 6, and I need to create over 100 input fields. Since these inputs are used in multiple forms, I want to create a dynamic form. However, I'm trying to figure out the best way to connect the input configurations to the correct objects.
My initial approach was to define all the input fields and store their values based on the object they belong to, but I encountered some challenges.
let inputs: FormBase<any>[] = [
new InputTextForm({
key: 'Id',
label: 'Id',
value: '',
required: true,
order: 1
}),
new InputTextForm({
key: 'Name',
label: 'Name',
value: '',
required: true,
order: 2
}),
new InputTextForm({
key: 'Description',
label: 'Description',
order: 3
}),
new InputTextForm({
key: 'CanSplit',
label: 'Can Split',
order: 4
}),
new InputTextForm({
key: 'PisRate',
label: 'PIS Rate',
order: 5
}),
];
return inputs.sort((a, b) => a.order - b.order);
}
All objects are named InputTextForm, and I will need to filter them based on their keys. How can I filter and push an InputTextForm instance to another array based on its key?