1
I’m using the selectize and Angularjs, my selectize is configured like this:
in the 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 = [];
in the view
<div class="uk-width-medium-1-1">
<label>Fornecedor</label>
<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;
however I need to get also the labelFiel, ie the text that is in the seclect, but I could not find out how, how could make it?
I tried already:
var xx = document.getElementById('selectize_fornecedor').value;
but it doesn’t work
is supplier or drug ? because your JS is written medicine and its html is supplier. But what will make you pick the correct value is your ng-model, which in your case is: $Scope.objFornecedor.selectedFornecedor;
– Hugo Lima
in this case ai Hugo, he picks up the id, but I need to get the text that appears in the box
– alessandre martins
Dude, in this selectize you’re gonna have to go rogue... I couldn’t think of any other way to help you out than this. Within your options(itemsMedication) you place an onChange like this: onChange:Function(v){Alert(Document.querySelectorAll('[data-value='+v+']')[0]. outerText);}
– Hugo Lima