Combo Satanico

0 respostas
javascript
juniorsatanas

Alguem pode da uma dica sobre um problema em um combo ? quando eu salvo ele diz que o valor selecionado e nulo !!

import { Component, OnInit } from @angular/core;

import { Company, RequestCreateCompany } from ‘…/company.module;

import { FormGroup } from @angular/forms;

import { CompanyService } from ‘…/company.service;

import { SectorService } from ‘…//sector/sector.service;

import { Sector } from ‘…//sector/sector.module;

declare var $: any;

@Component({

selector: app-create-company,

templateUrl: ./create-company.component.html,

styleUrls: [./create-company.component.css]

})

export class CreateCompanyComponent implements OnInit {
showSpinner = false;
response: Company;
companyForm: FormGroup;
responseSector: Sector;
results$;

request: RequestCreateCompany = {
    cnpj: '',
    mainActivity: '',
    market: '',
    name: '',
    setorialClassification: '',
    site: '',
    status: 'ATIVO',
    sector: null
}

constructor(private companyService: CompanyService,
            private sectorService: SectorService,
) {
}

ngOnInit() {

    this.showSpinner = true;
    this.sectorService.getSector().subscribe(dados => this.responseSector = dados);

     if (this.results$ == null) {
        setTimeout(() => {
            this.showSpinner = false;
        }, 1000);
    }

}

save() {

    this.companyService.createCompany(this.request).subscribe(res => this.response = res);
    console.log(this.responseSector);
    if (this.response) {
        console.log(this.response);
        this.showNotificationSucesso();
        this.limpa()
    } else {
        console.log(this.response);
        this.showNotificationErro();
    }

}


<div class="col-md-3">
                    <div class="form-group" class="example-full-width">
                        <label for="sector">Setor</label>
                        <select class="form-control" id="sector" [(ngModel)]="request.sector">
                            <option  *ngFor="let responseSector of responseSector" [value]="responseSector.id">

                                {{responseSector.id}} => {{responseSector.description}}

                            </option>
                        </select>
                    </div>
                    </div>
Criado 30 de abril de 2020
Respostas 0
Participantes 1