#Form Select & Code quality

2 messages · Page 1 of 1 (latest)

slender gate
#

I got register form with 4 to 5 select fields the values are too many in register.component.ts . Can I import all 4 to 5 values from other file or any better way to write the code. I want to be in 1st method.

    /* 1st method */
    companySize = SelectionHelper.companySize;

    /* 2nd method*/
    companySize = [
        {
            label: 'projectEnquiry',
            value: 'Project Enquiry'
        },
        {
            label: 'technicalSupport',
            value: 'Technical support'
        },
        {
            label: 'salesPrice',
            value: 'Sales / Pricing'
        },
        {
            label: 'leadTime',
            value: 'Lead Time'
        },
        {
            label: 'others',
            value: 'General'
        }
    ];
            <select formControlName="companySize">
                    <option *ngFor="let option of companySize" [value]="option.value">{{ option.label }}</option>
                </select> 
static lynx
#

Of course you can. I would rename the variable though: it's an array, so it should be plural, and it doesn't seem to have anything to do with the size of a company, so I wouldn't name it companySize.