doubts with select and angular Js


I'm using select and angularJs, my selectize is set up like this :

no controller

//configurando o select mrdicamento
$scope.selectize_medicamento = {
    plugins: {
        'remove_button': {
            label: ''
    maxItems: 1,
    valueField: 't0051_id_medicamento',
    labelField: 't0051_nome',
    searchField: 't0051_alldata',
    placeholder: "Medicamanto",
    create: false,

$scope.objMedicamento = { "selectedMedicamento ": null };
$scope.selectedMedicamento = [];
$scope.itemsMedicamento = [];

na view

<div class="uk-width-medium-1-1">
     <selectize id="selectize_medicamento" required config="selectize_mediacmento" options="itemsMedicamento" position="bottom" ng-model="objMedicamento.selectedMedicamento"></selectize>

to get the valueField:

 var id_med = $scope.objMedicamento.selectedMedicamento;

But I need to get the labelFiel, that is, the text that is in the seclect, but I could not figure out how, how could I frazer it?

I've tried:

 var xx = document.getElementById('selectize_fornecedor').value;

But it does not work

asked by anonymous 06.01.2017 / 08:21

1 answer


Assuming your HTML structure is this, you can get text from an earlier node using previousElementSibling .


var label = document.getElementById("selectize_fornecedor").previousElementSibling;
<div class="uk-width-medium-1-1">
  <selectize  id="selectize_fornecedor"></selectize >
06.01.2017 / 10:30