Keep selected a combobox with angle

0

I'm using angularJs to populate the data of a form within a modal. I have a editarSolicitacao(solicitacao) function that is executed from the click event of the button. When the modal opens the field is selected however the selection disappears quickly and I noticed that the following tag is created in HTML

<option value="? number:7 ?"></option>


 <select ng-model="solicitacao.setor_id" class="form-control" required>
                        <option value="">(Selecione)</option>
                        <option ng-value="setor.id" ng-repeat="setor in setores" ng-bind="setor.id" ng-selected="setor.id == solicitacao.setor_id"></option>
                        </select>

Someone has gone through something like this and can you tell me how to proceed?

My function opens the modal and prefixes the form:

$scope.editarSolicitacao = function(solicitacao)
    {
        unidadeMedidas();
        setores();

        $scope.solicitacao = solicitacao;
        $scope.produtos = $scope.solicitacao.produtos_adicionados;
        $scope.showProdutos = true;

        modal();
    }



 unidadeMedidas = function()
    {
         $http({
            method: 'GET',
            url: '/unidade-medida/consultar'
        }).then(function(response){
            $scope.unidades = response.data;

        },function(responseError){
            wgmAlert(responseError.statusText);
        });
    }



    setores = function()
    {
        $http({
            method: 'GET',
            url: '/setores'
        }).then(function(response){
            $scope.setores = response.data;

        },function(responseError){
            wgmAlert(responseError.statusText);
        });
    }



    modal = function()
    {
        $scope.modal = Modal({
            animation: 'slideDown',
            draggable: true,
            width: $(window).outerWidth() -300,
            title: 'Solicitação',
            height: $(window).outerHeight() - 100,
            template: $('#template-form-solicitacao').html(),
            clickOut: false
        },$scope);
        $scope.modal.show();
    }
    
asked by anonymous 09.08.2016 / 19:07

1 answer

1

How did you create your own?

Are you setting up ng-model? How are the options being generated?

An example:

<select ng-model="suamodel" name="selectUm">
<options ng-repeat="optionsValue as modelComOptions" value={{optionsValue.id}}>{{ optionsValue.descricao }}</options>
</select>

Angular documentation

    
09.08.2016 / 19:27