It turns out that I have two selections, one parent and one child that will load depending on what was selected in the parent. All the data is brought from an API with aJax of angularJS, and everything goes well, it turns out that I print on the screen the result brought for the child select and it is correct, only that in the select the values are not updated ...
This is the controller
app.controller('acto', function($rootScope,$scope,$http,$localStorage,$location,$window) { $rootScope.validateToken(); $rootScope.objeto = "Programador de Actos"; if (typeof $localStorage.evento !== 'undefined') { if($localStorage.evento !== "") { $scope.data = $localStorage.evento; } } $('#post').on('click', function() { if($scope.data==undefined) { $rootScope.toast("Rellene los campos"); return; } if($scope.data.titulo==undefined || $scope.data.titulo == "") { $rootScope.toast("Campo 'Titulo' vacio"); return; } if($scope.data.inicio==undefined || $scope.data.inicio == "") { $rootScope.toast("Campo 'Inicio' vacio"); return;} if($scope.data.fin==undefined || $scope.data.fin == "") { $rootScope.toast("Campo 'Fin' vacio"); return;} if($scope.data.descripcion==undefined || $scope.data.descripcion == "") { $rootScope.toast("Campo 'Descripcion' vacio"); return;} $rootScope.post('api/acto',$scope.data).then(function(response) { var date = $rootScope.formatDate($scope.data.inicio, "yyyy-MM-dd"); localStorage.removeItem("ngStorage-evento"); $scope.data = {}; $window.location.href = '#!/programador/' + date; }, function() { $rootScope.alert("Ocurrio un Error interno"); }); }); function obtenerTipoTribunal($http,$scope) { $http.get('api/tipo_de_tribunal',{ headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': $localStorage.token } }).then(function(data) { var array = data == null ? [] : (data.data.data instanceof Array ? data.data.data : [data.data.data]); $scope.JSONtipoTribunal = array; $scope.selCategorias = $scope.JSONtipoTribunal; }, function(response) { console.log('Error: ' + response); }); } function obtenerTribunal($http,$scope,idCategoria){ console.log(idCategoria); var filtro = { donde : "where id_tipo_tribunal = " + idCategoria }; var filter = JSON.stringify(filtro).toString(); $http.get('api/tribunal?filter=' + filter,{ headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Authorization': $localStorage.token } }).then(function(data) { var array = data == null ? [] : (data.data.data instanceof Array ? data.data.data : [data.data.data]); $scope.JSONTribunal = array; $scope.selPistos = $scope.JSONTribunal; }, function(response) { console.log('Error: ' + response); }); } $scope.mostrarPistos = function() { // $scope.selCategorias NOS TRAE EL VALOR DEL SELECT DE CATEGORIAS obtenerTribunal($http,$scope,$scope.selCategorias); }; angular.element(document).ready(function() { $rootScope.tribunal = []; $rootScope.tipo_de_tribunal = []; obtenerTipoTribunal($http,$scope); }); });
and this HTML
<select ng-model="selCategorias" class="form-control" ng-change="mostrarPistos()" ng-options="x.id as x.descripcion for x in JSONtipoTribunal"> <option value="" disabled selected>Selecciona una opcion</option> </select> <select ng-model="selPistos" class="form-control" ng-options="y.id as y.numero for y in JSONTribunal"> <option value="" disabled selected>Selecciona una opcion</option> </select>