Here is my current select setup:
<select class="form-control" ng-change="filtro(selected)" ng-init="Catalogos[0]" ng-model="selected" ng-options="item.Nombre for item in Catalogos"></select>
I am trying to retrieve the index value of the selected item using:
$scope.selected
However, instead of getting the index of the selected list, I am getting parameters from the database. How can I retrieve the index value? Regards
I tried following maddockst's suggestion:
$scope.filtro = function (item) {
$scope.Catalogos.indexOf(item);
}
But when using this, I get different values instead of the index https://i.sstatic.net/385dp.png
This is how my code looks now:
HTML
<select class="form-control" ng-change="filtro(selected)" ng-init="Catalogos[0]" ng-model="selected" ng-options="Catalogos as item.Nombre for item in Catalogos"></select>
JS
function editar() {
$scope.filtro = function (item) {
alert($scope.Catalogos.indexOf(item));
console.log(index);
}
($("#tabla_catalogos tr.selected").hasClass("selected"));
{
var table = $('#tabla_catalogos').DataTable();
var row = table.rows('.selected').data();
var id = table.cell(row[0], 1).data();
//Retrieve the id related to the selected column
$state.go("root.detalleregistros", { codigo: row[0].Codigo, nombre: row[0].Nombre, catalogoid: row[0].ID, catalogoselected: $scope.filtro });
}
}
But I always receive -1
in the alert popuphttps://i.sstatic.net/vuAPT.png