ng-model with undefined value in the controller

1

I have a very strange problem. I have some filters that look like this.

<div ng-show="filtroReduzido" class="col-md-2">
   <div class="form-group">
        <label>Codigo Reduzido</label>
           <div class="form-group form-md-line-input no-hint right" style="padding-top: 3px;">
             <select id="servico"  
                     name="servico"  
                     chosen  
                     width="150"
                     allow-single-deselect="true"
                     ng-model="vm.filtro.des_servico"
                     style="width:100%"
                     ng-options="clienteFiltro as cliente.Des_Servico for cliente in vm.importacaoSiltDet |unique:'Des_Servico'| orderBy:'Des_Servico'"></select>
      </div>
    </div>
</div>

In the controller I declare the "filter"

 vm.filtro = {};

In my function I call this ng-model but it comes undifined . The dateDe and dateAte are receiving the parameters normally, and the vm.relatorio is declared equal vm.filtro .

I do not understand why the variables test2 and test3 are coming undifined , am I forgetting any steps? maybe bind the values of the filter parameters?

vm.filtrarDetFiltrado = function () {
            debugger;
            var dateDe = formatarData(vm.relatorio.dataDe);
            var dateAte = formatarData(vm.relatorio.dataAte);
            var test2 = vm.filtro.des_servico;
            var test3 = vm.filtro.Des_Servico;

    
asked by anonymous 03.03.2017 / 13:13

1 answer

0

The problem was in the alias of ng-options, I imagined that it did not matter, but the old one was

ng-options="clienteFiltro as cliente.Des_Servico for cliente in vm.importacaoSiltDet

It should be getting lost in the clientFilter, corrected using ng-options as follows.

ng-options="cliente.Des_Servico as cliente.Des_Servico for cliente in vm.importacaoSiltDet
    
03.03.2017 / 14:49